﻿---@diagnostic disable: trailing-space
local extension = Package:new("moepack_flower")
extension.extensionName = "moepack"

Fk:loadTranslationTable{
  ["moepack_flower"] = "萌包-百花",
}
local U = require "packages.utility.utility"

local MoeFunc = require "packages.moepack.moepack_function"





local emo__kehen = fk.CreateActiveSkill{
  name = "emo__kehen",
  frequency = Skill.Limited,
  anim_type = "offensive",
  card_num = 0,
  card_filter = Util.FalseFunc,
  target_num = 0,
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryGame) == 0 and player:isWounded()
    and table.find(Fk:currentRoom().players, function (p) return p.dead end)
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local targets = table.map(table.filter(room.players, function(p) return p.dead end), function(p) return "seat#" .. tostring(p.seat) end)
    local target
    if #targets > 0 then
      local targetStr = room:askForChoice(player, targets, self.name, "#emo__kehen-target")
      if targetStr then
        target = tonumber(string.sub(targetStr, 6))
        for _, p in ipairs(room.players) do
          if p.seat == target then
            target = p
            break
          end
        end
      end
    end
    if target then
      room:doIndicate(player.id, {target.id})
      room:swapSeat(player, target)
    end
    local cards = table.filter(room.discard_pile, function (id) return Fk:getCardById(id).is_damage_card end)
    if #cards > 0 then
      room:moveCards({
        ids = table.random(cards, 3),
        to = player.id,
        toArea = Card.PlayerHand,
        moveReason = fk.ReasonPrey,
        skillName = self.name,
      })
    end
  end,
}
moe__manxue:addSkill(emo__kehen)

Fk:loadTranslationTable{
  ["emo__kehen"] = "渴恨",
  [":emo__kehen"] = "限定技，出牌阶段，若你已受伤，你可以与一名死亡角色交换位置，然后从弃牌堆获得三张伤害牌。",
  ["#emo__kehen-target"] = "渴恨：与一名死亡角色交换位置",

  ["$emo__kehen1"] = "以血还血，以牙还牙",
  ["$emo__kehen2"] = "生啖敌肉，渴饮仇血",
}

local moe__qingqiong = General(extension, "moe__qingqiong", "moe", 4, 4, General.Female)
moe__qingqiong.subkingdom = "qun"

local emo__xiongyan = fk.CreateActiveSkill{
  name = "emo__xiongyan",
  anim_type = "offensive",
  prompt = "#emo__xiongyan",
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) < 1 
  end,
  card_num = 0,
  card_filter = Util.FalseFunc,
  target_num = 1,
  target_filter = function(self, to_select, selected)
    return #selected == 0 and to_select ~= Self.id
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    target:drawCards(1, self.name)
    player:drawCards(1, self.name)
    local card = Fk:cloneCard("fire_attack")
    card.skillName = self.name
    if player.dead or target:isKongcheng() or player:prohibitUse(card) or player:isProhibited(target, card) then return end
    local use = {from = player.id, tos = {{target.id}}, card = card} 
    room:useCard(use)
    if use.damageDealt then
      room:useVirtualCard("duel", nil, player, target, self.name)
    else
      room:useVirtualCard("duel", nil, target, player, self.name)
    end
  end,
}

moe__qingqiong:addSkill(emo__xiongyan)

local emo__zhuimie = fk.CreateTriggerSkill{
  name = "emo__zhuimie",
  anim_type = "offensive",
  events = {fk.CardResponding},
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local tos = room:askForChoosePlayers(player, table.map(room:getAlivePlayers(), Util.IdMapper), 1, 1, "#emo__zhuimie-target", self.name, true)
    if #tos > 0 then
      self.cost_data = {tos = tos}
      return true
    end
  end,  
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(self.cost_data.tos[1])
    room:damage { from = player, to = to, damage = 1, skillName = self.name, damageType = fk.ThunderDamage }
  end,
}
emo__zhuimie:addAttachedKingdom("moe")
moe__qingqiong:addSkill(emo__zhuimie)

local emo__buxi = fk.CreateTriggerSkill{
  name = "emo__buxi",
  anim_type = "drawcard",
  events = {fk.Damage, fk.Damaged},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    return player == target and player:hasSkill(self) and data.card and data.card.type == Card.TypeTrick
  end,
  on_trigger = function(self, event, target, player, data)
    for _ = 1, data.damage do
      if player.dead then break end
      self:doCost(event, target, player, data)
    end 
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(1, self.name)
  end,
}
emo__buxi:addAttachedKingdom("qun")
moe__qingqiong:addSkill(emo__buxi)


Fk:loadTranslationTable{
  ["moe__qingqiong"] = "青穹",
  
  ["emo__xiongyan"] = "凶焰",
  [":emo__xiongyan"] = "出牌阶段限一次，你可以令一名其他角色与你各摸一张牌，然后视为对其使用了一张【火攻】，若此【火攻】造成了伤害，令你视为对其使用了一张【决斗】，否则视为其对你使用了一张【决斗】。",
  ["#emo__xiongyan"] = "凶焰：选择一名其他角色，你与其各摸一张牌，再视为对其用【火攻】",
  
  ["emo__zhuimie"] = "追灭",
  [":emo__zhuimie"] = "萌势力技，你打出一张牌时，可以对一名角色造成1点雷电伤害。",
  ["#emo__zhuimie-target"] = "追灭：对一名角色造成1点雷电伤害",

  ["emo__buxi"] = "不息",
  [":emo__buxi"] = "群势力技，锁定技，你造成或受到1点锦囊伤害后摸一张牌。",
}

local moe__linshi = General(extension, "moe__linshi", "moe", 4, 4, General.Female)
moe__linshi.subkingdom = "qun"

local emo__hantian = fk.CreateActiveSkill{
  name = "emo__hantian",
  anim_type = "offensive",
  prompt = "#emo__hantian",
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) < 1 
  end,
  card_num = 1,
  card_filter = function(self, to_select, selected)
    return #selected == 0
  end,
  target_num = 1,
  target_filter = function(self, to_select, selected, cards)
    return #selected == 0 and to_select ~= Self.id and #cards == 1
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local to = room:getPlayerById(effect.tos[1])
    room:moveCardTo(effect.cards[1], Player.Hand, to, fk.ReasonGive, self.name, nil, false, player.id)
    for _ = 1, 2 do
      if player.dead or to.dead then break end
      room:useVirtualCard("fire_attack", nil, player, to, self.name)
    end
  end,
}

local emo__hantian_trigger = fk.CreateTriggerSkill{
  name = "#emo__hantian_trigger",
  anim_type = "drawcard",
  events = {fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and data.card.name == "fire_attack" and data.extra_data and data.extra_data.emo__hantian
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local suits = data.extra_data.emo__hantian
    local cards = {}
    for _, suit in ipairs(suits) do
      local ids = room:getCardsFromPileByRule(".|.|"..suit)
      if #ids > 0 then table.insert(cards, ids[1]) end
    end
    if #cards > 0 then
      room:moveCards({
        ids = cards,
        to = player.id,
        toArea = Card.PlayerHand,
        moveReason = fk.ReasonPrey,
        skillName = self.name,
        moveVisible = false,})
    end
  end,

  refresh_events = {fk.CardShown},
  can_refresh = function(self, event, target, player, data)
    if target == player then
      local e = player.room.logic:getCurrentEvent():findParent(GameEvent.UseCard)
      if e then
        local use = e.data[1]
        return use and use.card.name == "fire_attack"
      end
    end
  end,
  on_refresh = function(self, event, target, player, data)
    local e = player.room.logic:getCurrentEvent():findParent(GameEvent.UseCard)
    if e then
      local use = e.data[1]
      use.extra_data = use.extra_data or {}
      use.extra_data.emo__hantian = use.extra_data.emo__hantian or {}
      table.insertIfNeed(use.extra_data.emo__hantian, Fk:getCardById(data.cardIds[1]):getSuitString())
    end
  end,
}
emo__hantian:addRelatedSkill(emo__hantian_trigger)

moe__linshi:addSkill(emo__hantian)

local emo__chidi = fk.CreateTriggerSkill{
  name = "emo__chidi",
  anim_type = "offensive",
  events = {fk.AfterCardsMove},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and player:isKongcheng() then
      for _, move in ipairs(data) do
        if move.from == player.id then
          for _, info in ipairs(move.moveInfo) do
            if info.fromArea == Card.PlayerHand then
              return true
            end
          end
        end
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    local tos = player.room:askForChoosePlayers(player, table.map(player.room.alive_players, Util.IdMapper), 1, 1, "#emo__chidi-choose", self.name, true)
    if #tos > 0 then
      self.cost_data = {tos = tos}
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(self.cost_data.tos[1])
    room:damage { from = player, to = to, damage = 1, skillName = self.name , damageType = fk.FireDamage }
  end,
}

emo__chidi:addAttachedKingdom("moe")
moe__linshi:addSkill(emo__chidi)

moe__linshi:addSkill("emo__buxi")

Fk:loadTranslationTable{
  ["moe__linshi"] = "林诗",

  ["emo__hantian"] = "熯天",
  [":emo__hantian"] = "出牌阶段限一次，你可以将一张牌交给一名其他角色，视为对其使用两张【火攻】。每当任意【火攻】结算后，你摸与目标角色展示的牌花色相同的牌各一张。",
  ["#emo__hantian_trigger"] = "熯天",
  ["#emo__hantian"] = "熯天：将一张牌交给一名其他角色，视为对其使用两张【火攻】",

  ["emo__chidi"] = "炽地",
  [":emo__chidi"] = "萌势力技，每当你失去最后的手牌时，你可以对一名角色造成一点火焰伤害。",
  ["#emo__chidi-choose"] = "炽地：可以对一名角色造成一点火焰伤害",
}

local moe__qingxi = General(extension, "moe__qingxi", "moe", 4, 4, General.Female)

local emo__kunlong = fk.CreateTriggerSkill{
  name = "emo__kunlong",
  anim_type = "control",
  events = {fk.TargetSpecified, fk.TurnEnd},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and target == player then
      if event == fk.TargetSpecified then
        local to = player.room:getPlayerById(data.to)
        return to and to ~= player and not to.dead and
        (data.card.is_damage_card or (data.card.type == Card.TypeTrick and not data.card.multiple_targets))
      else
        return player:usedSkillTimes(self.name) == 0
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    if event == fk.TargetSpecified then
      if player.room:askForSkillInvoke(player, self.name, nil, "#emo__kunlong-invoke:"..data.to) then
        self.cost_data = {tos = {data.to}}
        return true
      end
    else
      local use = U.askForUseVirtualCard(player.room, player, "slash", nil, self.name, "#emo__kunlong-slash", true, true, true, true, nil, true)
      if use then
        self.cost_data = use
        return true
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.TargetSpecified then
      local to = room:getPlayerById(data.to)
      local all_choices = {"emo__kunlong1", "emo__kunlong2", "emo__kunlong3", "emo__kunlong4"}
      local chosen = {}
      for i = 1, 2 do
        if to.dead then break end
        local choices = {}
        if not to:isKongcheng() then table.insert(choices, all_choices[1]) end
        if not to.chained then table.insert(choices, all_choices[2]) end
        if to:getMark("@@emo__kunlong") == 0 then table.insert(choices, all_choices[3]) end
        if not player.dead then table.insert(choices, all_choices[4]) end
        choices = table.filter(choices, function (ch) return not table.contains(chosen, ch) end)
        if #choices == 0 then break end
        local choice = room:askForChoice(to, choices, self.name, "#emo__kunlong-choice", nil, all_choices)
        table.insert(chosen, choice)
        if choice == all_choices[1] then
          local num = (to:getHandcardNum() + 1) // 2
          room:askForDiscard(to, num, num, false, self.name, false)
        elseif choice == all_choices[2] then
          to:setChainState(true)
        elseif choice == all_choices[3] then
          room:setPlayerMark(to, "@@emo__kunlong", 1)
        else
          player:drawCards(1, self.name)
        end
      end
    else
      room:useCard(self.cost_data)
    end
  end,

  refresh_events = {fk.AfterTurnEnd},
  can_refresh = function(self, event, target, player, data)
    return target == player and player:getMark("@@emo__kunlong") ~= 0
  end,
  on_refresh = function(self, event, target, player, data)
    player.room:setPlayerMark(player, "@@emo__kunlong", 0)
  end,
}

local emo__kunlong_invalidity = fk.CreateInvaliditySkill {
  name = "#emo__kunlong_invalidity",
  invalidity_func = function(self, player, skill)
    return player:getMark("@@emo__kunlong") ~= 0 and skill:isPlayerSkill(player)
  end
}
emo__kunlong:addRelatedSkill(emo__kunlong_invalidity)

moe__qingxi:addSkill(emo__kunlong)


Fk:loadTranslationTable{
  ["emo__kunlong"] = "困龙",
  [":emo__kunlong"] = "每当你使用伤害牌或单体锦囊牌指定其他角色为目标后，你可以令其选择两项：1.弃置半数（向上取整）的手牌；2.横置；3.技能失效直到其回合结束；4.令你摸一张牌。你回合结束时，若本回合未发动此技能，你可视为使用一张【杀】。",

  ["@@emo__kunlong"] = "被困龙",
  ["#emo__kunlong-invoke"] = "困龙：你可以令 %src 选择两项：弃牌、横置、技能无效、令你摸牌",
  ["#emo__kunlong-choice"] = "困龙：请选择1项，共2项",
  ["emo__kunlong1"] = "弃置一半手牌",
  ["emo__kunlong2"] = "横置",
  ["emo__kunlong3"] = "技能失效直到你回合结束",
  ["emo__kunlong4"] = "令其摸一张牌",
  ["#emo__kunlong-slash"] = "困龙：你可以视为使用一张【杀】",
}




local emo__qingsun = fk.CreateTriggerSkill{
  name = "emo__qingsun",
  events = {fk.RoundStart, fk.AfterCardsMove},
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) then return false end
    if event == fk.RoundStart then
      return table.find(player.room.alive_players, function(p) return p:getMark("@emo__qingsun") == 0 end)
    else
      return data.extra_data and data.extra_data.emo__qingsun_check
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if event == fk.RoundStart then
      local targets = table.filter(room.alive_players, function(p) return p:getMark("@emo__qingsun") == 0 end)
      local tos = room:askForChoosePlayers(player, table.map(targets, Util.IdMapper), 1, 1, "#emo__qingsun-choose", self.name, true)
      if #tos > 0 then
        self.cost_data = tos[1]
        return true
      end
    else
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.RoundStart then
      local to = room:getPlayerById(self.cost_data)
      room:setPlayerMark(to, "emo__qingsun_target-round", 1)
      local num = #table.filter(to:getCardIds("h"), function (id) return Fk:getCardById(id).name == "jink" end)
      room:setPlayerMark(to, "@emo__qingsun", num > 0 and num or "0")
    else
      local targets = table.filter(room.alive_players, function(p) return #p:getCardIds("hej") > 0 end)
      if #targets > 0 then
        local tos = room:askForChoosePlayers(player, table.map(targets, Util.IdMapper), 1, 1, "#emo__qingsun-throw", self.name, true)
        if #tos > 0 then
          local to = room:getPlayerById(tos[1])
          local cid = room:askForCardChosen(player, to, "hej", self.name)
          room:throwCard({cid}, self.name, to, player)
        end
      end
      if player.dead then return end
      targets = table.filter(room.alive_players, function(p)
        return p:getMark("emo__qingsun_target-round") == 0 and p:getMark("@emo__qingsun") == 0
      end)
      if #targets > 0 then
        local tos = room:askForChoosePlayers(player, table.map(targets, Util.IdMapper), 1, 1, "#emo__qingsun-choose", self.name, true)
        if #tos > 0 then
          local to = room:getPlayerById(tos[1])
          room:setPlayerMark(to, "emo__qingsun_target-round", 1)
          local num = #table.filter(to:getCardIds("h"), function (id) return Fk:getCardById(id).name == "jink" end)
          room:setPlayerMark(to, "@emo__qingsun", num > 0 and num or "0")
        end
      end
    end
  end,

  refresh_events = {fk.AfterCardsMove},
  can_refresh = function(self, event, target, player, data)
    if player:getMark("@emo__qingsun") ~= 0 then
      for _, move in ipairs(data) do
        for _, info in ipairs(move.moveInfo) do
          if Fk:getCardById(info.cardId).name == "jink" then
            if (move.to == player.id and move.toArea == Player.Hand) or (move.from == player.id and info.fromArea == Player.Hand) then
              return true
            end
          end
        end
      end
    end
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(player, "@emo__qingsun", 0)
    data.extra_data = data.extra_data or {}
    data.extra_data.emo__qingsun_check = true
  end,
}

Fk:loadTranslationTable{
  ["emo__qingsun"] = "轻隼",
  [":emo__qingsun"] = "每轮开始时，你可以令一名角色获得“轻隼”标记，数量等同于其手牌中【闪】数量，当该角色获得或失去【闪】时移除此标记，然后你可弃置一名角色区域内一张牌，且你可令本轮未获得过此标记的角色获得“轻隼”标记。",
  ["#emo__qingsun-choose"] = "轻隼：你可令一名角色获得“轻隼”标记",
  ["#emo__qingsun-throw"] = "轻隼：你可弃置一名角色区域内一张牌",
  ["@emo__qingsun"] = "轻隼",

}

local moe__fangzhun = General(extension, "moe__fangzhun", "moe", 3, 3, General.Female)

local emo__tanmei = fk.CreateTriggerSkill{
  name = "emo__tanmei",
  anim_type = "control",
  events = {fk.TargetSpecified},
  can_trigger = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(data.to)
    if target == player and player:hasSkill(self) and to ~= player and not to.dead then
      if to:getMark("@@emo__tanmei") == 0 then 
        return true
      else
        return table.find(room:getOtherPlayers(player), function(p)
          return p:getMark("@@emo__tanmei") == 0 and (p:getNextAlive() == to or to:getNextAlive() == p) 
        end) 
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(data.to)
    if to:getMark("@@emo__tanmei") == 0 then
      if room:askForSkillInvoke(player, self.name, nil, "#emo__tanmei-invoke:"..data.to) then
        self.cost_data = {tos = {data.to}}
        return true
      end
    else
      local targets = table.filter(room:getOtherPlayers(player), function (p)
        return p:getMark("@@emo__tanmei") == 0 and (p:getNextAlive() == to or to:getNextAlive() == p) 
      end)
      local ids = table.filter(player:getCardIds("he"), function(id) return not player:prohibitDiscard(Fk:getCardById(id)) end)
      local tos, id = room:askForChooseCardAndPlayers(player, table.map(targets, Util.IdMapper), 1, 1,
      tostring(Exppattern{ id = ids }), "#emo__tanmei-choose:"..data.to, self.name, true)
      if #tos > 0 then
        self.cost_data = {tos = tos, cards = {id}}
        return true
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(self.cost_data.tos[1])
    if to:getMark("@@emo__tanmei") == 0 then 
      player:drawCards(1, self.name)
    else
      room:throwCard(self.cost_data.cards, self.name, player, player)
    end
    if not to.dead then
      room:setPlayerMark(to, "@@emo__tanmei", 1)
    end
  end,
}

local emo__tanmei_targetmod = fk.CreateTargetModSkill{
  name = "#emo__tanmei_targetmod",
  bypass_times = function(self, player, skill, scope, card, to)
    return player:hasSkill("emo__tanmei") and to and to:getMark("@@emo__tanmei") > 0 and card
  end,
  bypass_distances = function(self, player, skill, card, to)
    return player:hasSkill("emo__tanmei") and to and to:getMark("@@emo__tanmei") > 0 and card
  end,
}
emo__tanmei:addRelatedSkill(emo__tanmei_targetmod)
moe__fangzhun:addSkill(emo__tanmei)


local emo__qianfang = fk.CreateTriggerSkill{
  name = "emo__qianfang",
  events = {fk.EventPhaseEnd},
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(self) then 
      if player.phase == Player.Finish or player.phase == Player.Start then
        -- 确定至少有一个其他角色……
        local ok = false
        for _, p in ipairs(player.room:getOtherPlayers(player)) do
          if p:getMark("@@emo__tanmei") > 0 then
            ok = true
          else
            return false
          end
        end
        return ok
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local x = 0
    for _, p in ipairs(room:getOtherPlayers(player)) do
      if p:getMark("@@emo__tanmei") > 0 then
        room:setPlayerMark(p, "@@emo__tanmei", 0)
        x = x + 1
      end
    end
    player:drawCards(x, self.name)
    if player.dead then return end
    room:addPlayerMark(player, "emo__qianfang_extra-phase")
    player:gainAnExtraPhase(Player.Play, true)
  end,
}

moe__fangzhun:addSkill(emo__qianfang)

Fk:loadTranslationTable{
  ["emo__tanmei"] = "探梅",
  [":emo__tanmei"] = "每当你使用牌指定一名其他角色为目标后：<br>"..
  "1.若其没有“探梅”标记，你可摸一张牌，令其获得“探梅”标记。<br>"..
  "2.若其有“探梅”标记，你可弃一张牌，令与其相邻的另一名其他角色获得“探梅”标记。<br>"..
  "你对拥有“探梅”标记的角色使用牌没有次数和距离限制。",
  ["#emo__tanmei-invoke"] = "探梅：可摸一张牌并令 %src 获得“探梅”标记",
  ["#emo__tanmei-choose"] = "探梅：可弃一张牌令与 %src 相邻的另一名其他角色获得“探梅”标记",
  ["@@emo__tanmei"] = "探梅",

  ["emo__qianfang"] = "倩放",
  [":emo__qianfang"] = "准备阶段或结束阶段结束时，若所有其他角色均有“探梅”标记，你可以移去所有“探梅”标记并摸等量的牌，然后进行一个额外的出牌阶段。",
}

local moe__caihua = General(extension, "moe__caihua", "moe", 3, 3, General.Female)

local emo__shencheng = fk.CreateTriggerSkill{
  name = "emo__shencheng",
  anim_type = "control",
  events = {fk.TargetConfirmed, fk.GameStart},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    if event == fk.GameStart then
      return player:hasSkill(self)
    else
      local from = player.room:getPlayerById(data.from)
      return player:hasSkill(self) and target == player and from ~= player and not from:isKongcheng()
      and data.card.trueName == "slash" and not table.find(from:getCardIds("h"), function (id)
        return Fk:getCardById(id):getMark("@@emo__shencheng-inhand") > 0
      end)
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.GameStart then
      for _, p in ipairs(room:getOtherPlayers(player)) do
        for _, id in ipairs(p:getCardIds("h")) do
          room:setCardMark(Fk:getCardById(id), "@@emo__shencheng-inhand", 1)
        end
      end
    else
      local from = room:getPlayerById(data.from)
      local cards = room:askForCard(from ,1, 1, false, self.name, false, ".", "#emo__shencheng-give:"..player.id)
      room:moveCardTo(cards, Player.Hand, player, fk.ReasonGive, self.name, nil, false, from.id)
    end
  end,
}

local emo__shencheng_prohibit = fk.CreateProhibitSkill{
  name = "#emo__shencheng_prohibit",
  frequency = Skill.Compulsory,
  prohibit_use = function(self, player, card)
    if card and table.find(Fk:currentRoom().alive_players, function (p) 
      return p:hasSkill("emo__shencheng") and p ~= player and p.phase ~= Player.NotActive
    end) then
      local cardList = card:isVirtual() and card.subcards or {card.id}
      return #cardList > 0 and table.find(cardList, function (id)
        return Fk:getCardById(id):getMark("@@emo__shencheng-inhand") > 0
      end)
    end
  end,
  is_prohibited = function(self, from, to, card)
    if card and to:hasSkill("emo__shencheng") and from ~= to then
      local cardList = card:isVirtual() and card.subcards or {card.id}
      return #cardList > 0 and table.find(cardList, function (id)
        return Fk:getCardById(id):getMark("@@emo__shencheng-inhand") > 0
      end)
    end
  end,
}
emo__shencheng:addRelatedSkill(emo__shencheng_prohibit)

moe__caihua:addSkill(emo__shencheng)

local emo__siluan = fk.CreateActiveSkill{
  name = "emo__siluan",
  anim_type = "offensive",
  prompt = "#emo__siluan",
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  min_card_num = 1,
  card_filter = function(self, to_select, selected)
    return not Self:prohibitDiscard(Fk:getCardById(to_select))
    and #selected < #Fk:currentRoom().alive_players
  end,
  min_target_num = 1,
  target_filter = function(self, to_select, selected, cards)
    return #selected < #cards
  end,
  feasible = function (self, selected, selected_cards)
    return #selected > 0 and #selected == #selected_cards
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local throw = table.simpleClone(effect.cards)
    room:throwCard(throw, self.name, player, player)
    local tos = effect.tos
    room:sortPlayersByAction(tos)
    for _, pid in ipairs(tos) do
      local p = room:getPlayerById(pid)
      if not p.dead and not p.chained then
        p:setChainState(true)
      end
      if not p:isKongcheng() then
        local t = room:askForDiscard(p, 1, 1, false, self.name, false)
        if #t > 0 then
          table.insertIfNeed(throw, t[1])
        end
      end
    end
    if player.dead then return end
    local x = #table.filter(throw, function (id) return Fk:getCardById(id).name == "jink" end)
    if x > 0 then
      room:addPlayerMark(player, "@emo__siluan", x)
    end
  end,
}

local emo__siluan_delay = fk.CreateTriggerSkill{
  name = "#emo__siluan_delay",
  anim_type = "offensive",
  events = {fk.AfterCardUseDeclared},
  can_trigger = function(self, event, target, player, data)
    return target == player and data.card.name == "slash" and player:getMark("@emo__siluan") > 0
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local x = player:getMark("@emo__siluan")
    player.room:setPlayerMark(player, "@emo__siluan", 0)
    local card = Fk:cloneCard("fire__slash", data.card.suit, data.card.number)
    for k, v in pairs(data.card) do
      if card[k] == nil then
        card[k] = v
      end
    end
    if data.card:isVirtual() then
      card.subcards = data.card.subcards
    else
      card.id = data.card.id
    end
    card.skillNames = data.card.skillNames
    card.skillName = "emo__siluan"
    data.card = card
    data.additionalDamage = (data.additionalDamage or 0) + x
  end,
}
emo__siluan:addRelatedSkill(emo__siluan_delay)

moe__caihua:addSkill(emo__siluan)

Fk:loadTranslationTable{
  ["moe__caihua"] = "彩华嬢嬢",

  ["emo__shencheng"] = "深城",
  [":emo__shencheng"] = "锁定技，游戏开始时，你将其他角色的手牌标记为“城”，这些牌无法对你使用，或在你回合内使用。每当你成为其他角色使用【杀】的目标后，若其没有“城”，其须交给你一张手牌。",
  ["@@emo__shencheng-inhand"] = "城",
  ["#emo__shencheng_prohibit"] = "深城",
  ["#emo__shencheng-give"] = "深城：你须交给 %src 一张手牌",
  
  ["emo__siluan"] = "肆乱",
  [":emo__siluan"] = "出牌阶段限一次，你可以弃置任意张牌，令等量的角色横置并弃置一张手牌，然后若X大于0，你使用的下一张普通【杀】改为火【杀】，且伤害基数+X（X为以此法弃置的牌中【闪】的数量）。",
  ["@emo__siluan"] = "肆乱",
  ["#emo__siluan_delay"] = "肆乱",
  ["#emo__siluan"] = "肆乱：弃置任意张牌，令等量的角色横置并弃置一张手牌",
}

local moe__shixi = General(extension, "moe__shixi", "moe", 3, 4, General.Female)

local chuanshi_blacklist = {"moe__shixi", "zuoci", "ol_ex__zuoci", "js__xushao"}

local emo__chuanshi = fk.CreateActiveSkill{
  name = "emo__chuanshi",
  anim_type = "support",
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) < (#Fk:currentRoom().players > 5 and 2 or 1)
  end,
  card_num = 0,
  card_filter = Util.FalseFunc,
  target_num = 1,
  prompt = "#emo__chuanshi-prompt",
  target_filter = function (self, to_select, selected)
    local to = Fk:currentRoom():getPlayerById(to_select)
    return #selected == 0 and not table.contains(Self:getTableMark("emo__chuanshi_target"), to_select) and to.maxHp > 1
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local to = room:getPlayerById(effect.tos[1])
    local mark = player:getTableMark("emo__chuanshi_target")
    table.insert(mark, to.id)
    room:setPlayerMark(player, "emo__chuanshi_target", mark)
    room:changeMaxHp(to, -1)
    if to.dead or player.dead then return end
    local all_generals = room:getTag("emo__chuanshi_generals")
    if all_generals == nil then
      all_generals = {}
      for _, name in ipairs(room.general_pile) do
        if not table.contains(chuanshi_blacklist, name) and #Fk.generals[name]:getSkillNameList() == 2 then
          table.insert(all_generals, name)
        end
      end
      for _, p in ipairs(room.players) do
        table.removeOne(all_generals, p.general)
        table.removeOne(all_generals, p.deputyGeneral)
      end
      room:setTag("emo__chuanshi_generals", all_generals)
    end
    if #all_generals == 0 then return end
    local generalMap = {}
    for _, name in ipairs(all_generals) do
      local kingdom = Fk.generals[name].kingdom
      generalMap[kingdom] = generalMap[kingdom] or {}
      table.insert(generalMap[kingdom], name)
    end
    local names = U.getRandomCards(generalMap, 8)
    if #names == 0 then return end
    local name = room:askForGeneral(player, names, 1, true)
    table.removeOne(all_generals, name)
    room:setTag("emo__chuanshi_generals", all_generals)
    local skills = table.filter(Fk.generals[name]:getSkillNameList() , function(skill_name)
      local skill = Fk.skills[skill_name]
      return not to:hasSkill(skill, true) and (#skill.attachedKingdom == 0 or table.contains(skill.attachedKingdom, to.kingdom))
    end)
    if #skills == 0 then return end
    local choice = room:askForChoice(player, skills, self.name, "#emo__chuanshi-skill:"..to.id, true)
    room:handleAddLoseSkills(to, choice)
  end,
}
moe__shixi:addSkill(emo__chuanshi)

local emo__changsong = fk.CreateTriggerSkill{
  name = "emo__changsong",
  events = {fk.EventPhaseStart},
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Finish 
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local n = 0
    for _, s in ipairs(player.player_skills) do
      if s:isPlayerSkill(player) then
        n = n + 1
      end
    end
    if n == 0 then return end
    player:drawCards(n, self.name)
    if not player.dead then
      U.askForUseRealCard(room, player, nil, nil, self.name)
    end
  end,
}
moe__shixi:addSkill(emo__changsong)

Fk:loadTranslationTable{
  ["moe__shixi"] = "识兮",

  ["emo__chuanshi"] = "传史",
  [":emo__chuanshi"] = "每名角色限一次，出牌阶段限一次（本局角色数大于5则改为限两次），你可以令体力上限大于1的一名角色扣减1点体力上限，然后你从每个势力各一个技能数为2的武将中选择一个，令其获得该武将的一个技能。",
  ["#emo__chuanshi-prompt"] = "传史：令一名角色扣减1点体力上限，为其挑选一个技能",

  ["emo__changsong"] = "长诵",
  [":emo__changsong"] = "结束阶段开始时，你可以摸X张牌，然后可以使用一张手牌（X为你拥有的技能数）。",
}

local moe__morugui = General(extension, "moe__morugui", "moe", 3, 3, General.Female)

local emo__heyu = fk.CreateActiveSkill{
  name = "emo__heyu",
  anim_type = "special",
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryTurn) == 0
  end,
  min_card_num = 1,
  card_filter = function(self, to_select, selected)
    return Fk:currentRoom():getCardArea(to_select) ~= Player.Equip
  end,
  target_num = 0,
  prompt = "#emo__heyu-prompt",
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local basic, trick = {}, {}
    for name, card in pairs(Fk.all_card_types) do
      if not table.contains(Fk:currentRoom().disabled_packs, card.package.name) and not card.is_derived then
        if card.type == Card.TypeBasic then
          table.insertIfNeed(basic, card.name)
        elseif card.type == Card.TypeTrick then
          table.insertIfNeed(trick, card.name)
        end
      end
    end
    local all = table.connect(basic, trick)
    for _, id in ipairs(effect.cards) do
      local card = Fk:getCardById(id, true)
      local names = basic
      if card.type == Card.TypeTrick then
        names = trick
      elseif card.type == Card.TypeEquip then
        names = all
      end
      if #names > 0 then
        local name = table.random(names)
        room:setCardMark(card, "@@emo__heyu-inhand", name)
        Fk:filterCard(id, player)
      end
    end
    if #effect.cards > player.hp and player:isWounded() then
      room:recover { num = 1, skillName = self.name, who = player , recoverBy = player }
    end
  end,
}



local emo__yumo = fk.CreateTriggerSkill{
  name = "emo__yumo",
  anim_type = "support",
  events = {fk.HpChanged},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) then
      if target == player then
        return table.find(player.room:getOtherPlayers(player), function(p) return p.hp == player.hp end)
      else
        return target.hp == player.hp
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if target == player then
      local targets = table.filter(room:getOtherPlayers(player), function(p) return p.hp == player.hp end)
      if #targets == 0 then return false end
      local tos = room:askForChoosePlayers(player, table.map(targets, Util.IdMapper), 1, 1, "#emo__yumo-choose", self.name, true)
      if #tos > 0 then
        self.cost_data = tos[1]
        return true
      end
    else
      return room:askForSkillInvoke(player, self.name, nil, "#emo__yumo-invoke:"..target.id)
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local tos = {player.id}
    if target == player then
      table.insert(tos, self.cost_data)
    else
      table.insert(tos, target.id)
    end
    room:sortPlayersByAction(tos)
    for _, pid in ipairs(tos) do
      local p = room:getPlayerById(pid)
      if not p.dead then
        p:drawCards(1, self.name)
      end
    end
  end,
}
moe__morugui:addSkill(emo__yumo)


Fk:loadTranslationTable{
  

  ["emo__heyu"] = "荷语",
  [":emo__heyu"] = "出牌阶段限一次，你可以选择任意张手牌，这些牌中的非装备牌变为同类型的随机牌，装备牌变为随机非装备牌，然后若你选择的牌数大于当前体力值，你回复1点体力。",
  ["@@emo__heyu-inhand"] = "荷语",
  ["#emo__heyu_filter"] = "荷语",
  ["#emo__heyu-prompt"] = "荷语：选择任意张手牌变为随机牌！",

  ["emo__yumo"] = "予沫",
  [":emo__yumo"] = "①每当你的体力值变化后，可与体力值相同的一名其他角色各摸一张牌；<br>②每当一名其他角色体力值变化后，若与你相同，你可以与该角色各摸一张牌。",
  ["#emo__yumo-choose"] = "予沫：你可与体力值相同的一名其他角色各摸一张牌",
  ["#emo__yumo-invoke"] = "予沫：你可与 %src 各摸一张牌",
}

local moe__shiwushiyan = General(extension, "moe__shiwushiyan", "moe", 3, 3, General.Female)

local emo__xiaoyu = fk.CreateTriggerSkill{
  name = "emo__xiaoyu",
  anim_type = "masochism",
  events = {fk.Damaged},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player:usedSkillTimes(self.name, Player.HistoryTurn) < 3
    and data.from and not data.from.dead
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, nil, "#emo__xiaoyu-invoke:"..data.from.id)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = data.from
    local record = {}
    local tos = {to, player}
    for i, p in ipairs(tos) do
      local other = tos[i % 2 + 1]
      local choices = {"turnover", "emo__xiaoyu_otherside:"..other.id, "draw2"}
      local choice = room:askForChoice(p, choices, self.name)
      table.insert(record, table.indexOf(choices, choice))
    end
    for i,p in ipairs(tos) do
      local choice = record[i]
      local other = tos[i % 2 + 1]
      if choice and not p.dead then
        if choice == 1 then
          p:turnOver()
        elseif choice == 2 then
          if other:isAlive() then
            other:turnOver()
          end
        else
          p:drawCards(2, self.name)
        end
      end
    end
    if #record == 2 and record[1] == record[2] and not player.dead and player:isWounded() then
      room:recover({ who = player,  num = 1, skillName = self.name })
    end
  end,
}
moe__shiwushiyan:addSkill(emo__xiaoyu)

local emo__jinci = fk.CreateTriggerSkill{
  name = "emo__jinci",
  events = {fk.EventPhaseStart, fk.DrawNCards},
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if not (player:hasSkill(self) and target == player) then return false end
    if event == fk.EventPhaseStart then
      return player.phase == Player.Start
    else
      return player:getMark("@@emo__jinci-turn") > 0
    end
  end,
  on_cost = function(self, event, target, player, data)
    if event == fk.EventPhaseStart then 
      return player.room:askForSkillInvoke(player, self.name)
    else
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.EventPhaseStart then
      room:addPlayerMark(player, "@@emo__jinci-turn")
      room:addPlayerMark(player, MarkEnum.AddMaxCardsInTurn, 3)
    elseif event == fk.DrawNCards then
      data.n = data.n + 3
    end
  end,

  refresh_events = {fk.CardUsing},
  can_refresh = function(self, event, target, player, data)
    return player == target and player.phase == Player.Play and player:getMark("@@emo__jinci-turn") > 0
    and data.card.type ~= Card.TypeEquip and U.IsUsingHandcard(player, data)
  end,
  on_refresh = function(self, event, target, player, data)
    player.room:addPlayerMark(player, "emo__jinci_play-phase")
  end,
}

local emo__jinci_prohibit = fk.CreateProhibitSkill{
  name = "#emo__jinci_prohibit",
  prohibit_use = function(self, player, card)
    if player:getMark("@@emo__jinci-turn") > 0 and player:getMark("emo__jinci_play-phase") >= 3
    and card and card.type ~= Card.TypeEquip and player.phase == Player.Play then
      local subcards = Card:getIdList(card)
      return #subcards > 0 and table.every(subcards, function(id)
        return table.contains(player:getCardIds(Player.Hand), id)
      end)
    end
  end,
}
emo__jinci:addRelatedSkill(emo__jinci_prohibit)

moe__shiwushiyan:addSkill(emo__jinci)

Fk:loadTranslationTable{
  ["moe__shiwushiyan"] = "时妩时妍",

  ["emo__xiaoyu"] = "宵雨",
  [":emo__xiaoyu"] = "每回合限三次，每当你受到其他角色造成的伤害后，你可以与该角色同时选一项：1.翻面；2.令对方翻面；3.摸两张牌。若你与其选项相同，你回复1点体力。",
  ["#emo__xiaoyu-invoke"] = "宵雨：可令 %src 与你同时选一项：1.翻面；2.对方翻面；3.摸两张牌",
  ["emo__xiaoyu_otherside"] = "%src 翻面",

  ["emo__jinci"] = "矜词",
  [":emo__jinci"] = "准备阶段，你可以令本回合：摸牌阶段额外摸三张牌，出牌阶段至多使用三张非装备手牌，手牌上限+3。",
  ["@@emo__jinci-turn"] = "矜词",
}

local moe__nancheng = General(extension, "moe__nancheng", "moe", 3, 3, General.Female)

local emo__huibian = fk.CreateTriggerSkill{
  name = "emo__huibian",
  anim_type = "drawcard",
  events = {fk.CardUsing},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.card.suit ~= Card.NoSuit
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local suit = data.card:getSuitString()
    if "log_"..suit == player:getMark("@emo__huibian") then
      room:setPlayerMark(player, "@emo__huibian", 0)
      local suits = {suit}
      local cards = table.simpleClone(room.draw_pile)
      table.insertTable(cards, room.discard_pile)
      local get = {}
      while #cards > 0 and #suits < 3 do
        local id = table.remove(cards, math.random(#cards))
        local s = Fk:getCardById(id):getSuitString()
        if not table.contains(suits, s) then
          table.insert(get, id)
          table.insert(suits, s)
        end
      end
      if #get > 0 then
        room:moveCardTo(get, Card.PlayerHand, player, fk.ReasonPrey, self.name)
      end
    else
      room:setPlayerMark(player, "@emo__huibian", "log_"..suit)
    end
  end,
}
moe__nancheng:addSkill(emo__huibian)

local emo__xinbi = fk.CreateTriggerSkill{
  name = "emo__xinbi",
  anim_type = "defensive",
  events = {fk.DamageInflicted},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target == player and not player:isNude()
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local tos, cards = room:askForChooseCardsAndPlayers(player, 1, 9999, table.map(room:getOtherPlayers(player, false), Util.IdMapper),
    1, 1, ".", "#emo__xinbi-ask:::"..data.damage, self.name, true)
    if #tos > 0 then
      self.cost_data = {tos = tos, cards = cards}
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(self.cost_data.tos[1])
    local cards = self.cost_data.cards
    room:moveCardTo(cards, Card.PlayerHand, to, fk.ReasonGive, self.name, nil, false, player.id)
    data.damage = math.max(1, data.damage - #cards)
    if data.from and not data.from.dead and #cards > 1 then
      room:loseHp(data.from, 1, self.name)
    end
  end,
}

moe__nancheng:addSkill(emo__xinbi)

Fk:loadTranslationTable{
  ["moe__nancheng"] = "南城",
  
  ["emo__huibian"] = "慧辨",
  [":emo__huibian"] = "锁定技，每当你使用一张有花色的牌时，记录此牌的花色，若与你上一次记录花色相同，你获得花色不同且与此牌花色不同的两张牌，然后清空记录。",
  ["@emo__huibian"] = "慧辨",

  ["emo__xinbi"] = "心壁",
  [":emo__xinbi"] = "每当你受到伤害时，你可以将至少一张牌交给一名其他角色，并令此伤害值减少等量（至多减至1），若至少给出两张牌，令伤害来源失去一点体力。",
  ["#emo__xinbi-ask"] = "心壁：可以将任意牌交给一名角色，令你受到的伤害(%arg点)减少等量点(至多减至1)",
}

local moe__qiaoxiaozhou = General(extension, "moe__qiaoxiaozhou", "moe", 4, 4, General.Female)

local emo__raoliang = fk.CreateActiveSkill{
  name = "emo__raoliang",
  anim_type = "control",
  card_num = 1,
  card_filter = function(self, to_select, selected)
    return #selected == 0
  end,
  target_num = 1,
  target_filter = function (self, to_select, selected, cards)
    return #selected == 0 and to_select ~= Self.id and #cards == 1
    and Fk:currentRoom():getPlayerById(to_select):getMark("emo__raoliang_target-phase") == 0
  end,
  can_use = function(self, player)
    return player:getMark("@@emo__raoliang_fail-phase") == 0 and table.find(Fk:currentRoom().alive_players, function (p)
      return p ~= player and p:getMark("emo__raoliang_target-phase") == 0
    end)
  end,
  prompt = "#emo__raoliang-prompt",
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local to = room:getPlayerById(effect.tos[1])
    room:setPlayerMark(to, "emo__raoliang_target-phase", 1)
    local basic = Fk:getCardById(effect.cards[1]).type == Card.TypeBasic
    room:moveCardTo(effect.cards, Player.Hand, to, fk.ReasonGive, self.name, nil, false, player.id)
    local get
    if basic then
      if not to.dead and to:isWounded() then
        room:recover { num = 1, skillName = self.name, who = to , recoverBy = player}
      end
      local cards = table.filter(to:getCardIds("he"), function(id) return Fk:getCardById(id).type ~= Card.TypeBasic end)
      if #cards > 0 then
        get = table.random(cards)
      end
    else
      room:damage { from = player, to = to, damage = 1, skillName = self.name }
      local cards = table.filter(to:getCardIds("h"), function(id) return Fk:getCardById(id).type == Card.TypeBasic end)
      if #cards > 0 then
        get = table.random(cards)
      end
    end
    if player.dead then return end
    if get then
      room:moveCardTo(get, Player.Hand, player, fk.ReasonPrey, self.name, nil, false, player.id)
    else
      room:setPlayerMark(player, "@@emo__raoliang_fail-phase", 1)
    end
  end,
}
moe__qiaoxiaozhou:addSkill(emo__raoliang)

local emo__kongjing = fk.CreateTriggerSkill{
  name = "emo__kongjing",
  anim_type = "control",
  frequency = Skill.Compulsory,
  events = {fk.RoundStart},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and #player.room.alive_players > 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = table.random(room.alive_players)
    room:doIndicate(player.id, {to.id})
    local choice = room:askForChoice(player, {"emo__kongjing_choice1","emo__kongjing_choice2"},self.name, "#emo__kongjing-choice:"..to.id)
    local mark = to:getTableMark("@@emo__kongjing-round")
    table.insert(mark, choice)
    room:setPlayerMark(to, "@@emo__kongjing-round", mark)
  end,

  refresh_events = {fk.CardUsing, fk.DamageInflicted},
  can_refresh = function(self, event, target, player, data)
    if player == target and data.card and data.card.trueName == "slash" then
      if event == fk.CardUsing then
        return table.contains(player:getTableMark("@@emo__kongjing-round"), "emo__kongjing_choice1")
      else
        return table.contains(player:getTableMark("@@emo__kongjing-round"), "emo__kongjing_choice2")
      end
    end
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    if event == fk.CardUsing then
      data.additionalDamage = (data.additionalDamage or 0) + 1
    else
      data.damage = data.damage + 1
    end
    room:sendLog{ type = "#SkillDelayInvoked", from = player.id, arg = "emo__kongjing" }
  end,
}
moe__qiaoxiaozhou:addSkill(emo__kongjing)

Fk:loadTranslationTable{
  ["moe__qiaoxiaozhou"] = "乔潇舟",
  ["#moe__qiaoxiaozhou"] = "空灵之清潭",

  ["emo__raoliang"] = "绕梁",
  [":emo__raoliang"] = "出牌阶段对每名其他角色限一次，你可以选一项：1.交给其一张非基本牌，对其造成一点伤害，随机获得其一张基本牌；2.交给其一张基本牌，令其回复一点体力，随机获得其一张非基本牌。若你未获得牌，本阶段〖绕梁〗失效。",
  ["@@emo__raoliang_fail-phase"] = "绕梁失效",
  ["#emo__raoliang-prompt"] = "绕梁:交出非基本牌，对其造成伤害；交出基本牌，令其回复体力",

  ["emo__kongjing"] = "空境",
  [":emo__kongjing"] = "锁定技，每轮开始时，随机指定一名角色，你秘密选择一项：1.其本轮使用【杀】伤害+1；2.其本轮受到【杀】伤害+1。",
  ["@@emo__kongjing-round"] = "空境",
  ["#emo__kongjing-choice"] = "空境:选择 %src 本轮受到的影响",
  ["emo__kongjing_choice1"] = "其使用【杀】伤害+1",
  ["emo__kongjing_choice2"] = "其受到【杀】伤害+1",

  ["$emo__kongjing1"] = "清音空荡",
  ["$emo__kongjing2"] = "空灵之境",
}

local moe__muyang = General(extension, "moe__muyang", "moe", 1, 4, General.Female)

local emo__mengyin = fk.CreateTriggerSkill{
  name = "emo__mengyin",
  anim_type = "defensive",
  frequency = Skill.Compulsory,
  events = {fk.DamageInflicted},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target == player and player.hp == 1 and player.faceup
  end,
  on_use = function(self, event, target, player, data)
    player:turnOver()
    return true
  end,
}

local emo__linyuan_draw = fk.CreateTriggerSkill{
  name = "#emo__linyuan_draw",
  mute = true,
  main_skill = emo__mengyin,
  anim_type = "drawcard",
  frequency = Skill.Compulsory,
  events = {fk.AfterCardsMove , fk.EventPhaseStart , fk.GameStart},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and player:getHandcardNum() < 4 and player.phase == Player.NotActive then
      if event == fk.GameStart then
        return true
      elseif event == fk.AfterCardsMove then
        for _, move in ipairs(data) do
          return move.from == player.id
        end
      elseif event == fk.EventPhaseStart then
        return target == player
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    player.room:notifySkillInvoked(player, emo__mengyin.name, "drawcard")
    player:drawCards(4 - player:getHandcardNum(), emo__mengyin.name)
  end,
}
emo__mengyin:addRelatedSkill(emo__linyuan_draw)

moe__muyang:addSkill(emo__mengyin)

local emo__linyuan = fk.CreateTriggerSkill{
  name = "emo__linyuan",
  anim_type = "offensive",
  events = {fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target ~= player and not player:isKongcheng() and data.tos and table.contains(TargetGroup:getRealTargets(data.tos), player.id)
  end,
  on_cost = function (self, event, target, player, data)
    local use = U.askForUseRealCard(player.room, player, nil, ".|.|spade,club", self.name, "#emo__linyuan-use", nil, true)
    if use then
      self.cost_data = use
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local use = self.cost_data
    player.room:useCard(use)
  end,
}

moe__muyang:addSkill(emo__linyuan)


Fk:loadTranslationTable{
  ["moe__muyang"] = "木昜",
  
  ["emo__mengyin"] = "梦吟",
  [":emo__mengyin"] = "锁定技，①每当你受到伤害时，若你体力值为1且正面朝上，你翻至背面并防止之。②你的回合外，当你手牌数小于四张时，摸至四张。",
  ["#emo__mengyin-target"] = "梦吟：令一名其他角色弃置所有牌",

  ["emo__linyuan"] = "临渊",
  [":emo__linyuan"] = "当其他角色使用牌后，若目标含有你，你可以使用一张黑色手牌。",
  ["#emo__linyuan-use"] = "临渊：可以使用一张黑色手牌",
}

local moe__yelin = General(extension, "moe__yelin", "moe", 4, 4, General.Female)

local emo__duorui = fk.CreateTriggerSkill{
  name = "emo__duorui",
  anim_type = "drawcard",
  frequency = Skill.Compulsory,
  events = {fk.TargetSpecified},
  can_trigger = function(self, event, target, player, data)
    local to = player.room:getPlayerById(data.to)
    return target == player and to ~= player and not to.dead
    and (#MoeFunc.getPlayerSkills(player) == player:getHandcardNum() or #MoeFunc.getPlayerSkills(to) == to:getHandcardNum())
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, _, player, data)
    local room = player.room
    local to = room:getPlayerById(data.to)
    local beishui = #MoeFunc.getPlayerSkills(player) == player:getHandcardNum() and #MoeFunc.getPlayerSkills(to) == to:getHandcardNum()
    if beishui then
      room:askForDiscard(to, 1, 1, false, self.name, false)
      if not player.dead then
        player:drawCards(1, self.name)
      end
    else
      if to:isKongcheng() or room:askForDiscard(to, 1, 1, false, self.name, true, nil, "#emo__duorui-discard:"..player.id) == 0 then
        player:drawCards(1, self.name)
      end
    end
  end,
}
moe__yelin:addSkill(emo__duorui)


local emo__zhiti_active = fk.CreateActiveSkill{
  name = "emo__zhiti_active",
  card_num = 0,
  card_filter = Util.FalseFunc,
  min_target_num = 2,
  target_filter = function(self, to_select, selected)
    if #selected == 0 then return true end
    return Fk:currentRoom():getPlayerById(to_select):getHandcardNum() == Fk:currentRoom():getPlayerById(selected[1]):getHandcardNum()
  end,
}
Fk:addSkill(emo__zhiti_active)

local emo__zhiti = fk.CreateTriggerSkill{
  name = "emo__zhiti",
  anim_type = "offensive",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Finish
  end,
  on_cost = function(self, event, target, player, data)
    local _, dat = player.room:askForUseActiveSkill(player, "emo__zhiti_active", "#emo__zhiti-use", true)
    if dat then
      self.cost_data = {tos = dat.targets}
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    for _, pid in ipairs(self.cost_data.tos) do
      local to = room:getPlayerById(pid)
      if not to.dead then
        room:damage { from = player, to = to, damage = 1, skillName = self.name }
      end
    end
  end,
}
moe__yelin:addSkill(emo__zhiti)

Fk:loadTranslationTable{
  ["moe__yelin"] = "叶琳",

  ["emo__duorui"] = "度睿",
  [":emo__duorui"] = "锁定技，每当你使用牌指定其他角色为目标后，若你手牌数等于你技能数，或其手牌数等于其技能数，其需弃置一张手牌，否则你摸一张牌。若均满足，则背水",
  ["#emo__duorui-discard"] = "度睿：你需弃置一张手牌，否则 %src 摸一张牌",

  ["emo__zhiti"] = "知涕",
  [":emo__zhiti"] = "结束阶段，你可以对两名手牌数相同的角色各造成一点伤害。",
  ["emo__zhiti_active"] = "知涕",
  ["#emo__zhiti-use"] = "知涕：可选择两名手牌数相同的角色，对其造成1点伤害",
}

local moe__huanhong = General(extension, "moe__huanhong", "moe", 3, 3, General.Female)

local emo__qingmu = fk.CreateTriggerSkill{
  name = "emo__qingmu",
  anim_type = "drawcard",
  frequency = Skill.Compulsory,
  events = {fk.GameStart, fk.CardUsing, fk.CardResponding},
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) then return false end
    if event == fk.GameStart then
      return player:getMark("emo__qingmu_tar") == 0
    else
      return (target == player or target.id == player:getMark("emo__qingmu_tar"))
      and (data.card:getSuitString(true) == target:getMark("@emo__qingmu") or 
      data.card:getTypeString() == target:getMark("@emo__qingmu"))
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local list = {"basic", "trick", "equip", "log_spade", "log_club", "log_diamond", "log_heart"}
    if event == fk.GameStart then
      local targets = room:getOtherPlayers(player, false)
      if #targets == 0 then return end
      local tos = room:askForChoosePlayers(player, table.map(targets, Util.IdMapper), 1, 1, "#emo__qingmu-choose", self.name, false)
      local to = room:getPlayerById(tos[1])
      room:setPlayerMark(player, "emo__qingmu_tar", to.id)
      for _, p in ipairs({player, to}) do
        if p:getMark("@emo__qingmu") == 0 then
          room:setPlayerMark(p, "@emo__qingmu", table.random(list))
        end
      end
    else
      local to = player
      if target == player then
        to = room:getPlayerById(player:getMark("emo__qingmu_tar"))
        if not to or to.dead then
          room:setPlayerMark(player, "emo__qingmu_tar", 0)
          return
        end
      end
      room:doIndicate(target.id, {to.id})
      local mark = target:getMark("@emo__qingmu")
      local pat = mark:startsWith("log_") and (".|.|"..string.sub(mark, 5)) or (".|.|.|.|.|"..mark)
      local ids = room:getCardsFromPileByRule(pat)
      if #ids > 0 then
        room:moveCardTo(ids, Player.Hand, to, fk.ReasonJustMove, self.name)
      end
      if not target.dead then
        table.removeOne(list, mark)
        room:setPlayerMark(target, "@emo__qingmu", table.random(list))
      end
    end
  end,

  -- 对象死亡时令自己清理标记
  refresh_events = {fk.BuryVictim},
  can_refresh = function(self, event, target, player, data)
    return player:getMark("emo__qingmu_tar") == target.id
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(player, "emo__qingmu_tar", 0)
    room:setPlayerMark(player, "@emo__qingmu", 0)
  end,

  on_lose = function (self, player, is_death)
    local room = player.room
    local to = room:getPlayerById(player:getMark("emo__qingmu_tar"))
    room:setPlayerMark(player, "@emo__qingmu", 0)
    room:setPlayerMark(player, "emo__qingmu_tar", 0)
    if to and to:getMark("@emo__qingmu") ~= 0 and table.every(room.alive_players, function (p)
      return p:getMark("@emo__qingmu") ~= to.id
    end) then
      room:setPlayerMark(to, "@emo__qingmu", 0)
    end
  end,
}
moe__huanhong:addSkill(emo__qingmu)

local emo__chixie = fk.CreateTriggerSkill{
  name = "emo__chixie",
  anim_type = "support",
  frequency = Skill.Limited,
  events = {fk.EnterDying},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target.hp < player.hp and target.id == player:getMark("emo__qingmu_tar")
    and player:usedSkillTimes(self.name, Player.HistoryGame) == 0
  end,
  on_cost = function(self, event, target, player, data)
    if player.room:askForSkillInvoke(player, self.name, nil, "#emo__chixie-invoke:"..target.id) then
      self.cost_data = {tos = {target.id}}
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:recover { num = player.hp - target.hp, skillName = self.name, who = target, recoverBy = player }
    if target:isAlive() then
      room:setPlayerMark(target, "@@emo__chixie-turn", 1)
    end
  end,
}

local emo__chixie_prohibit = fk.CreateProhibitSkill{
  name = "#emo__chixie_prohibit",
  is_prohibited = function (self, from, to, card)
    return card and card.is_damage_card and to:getMark("@@emo__chixie-turn") > 0
  end,
}
emo__chixie:addRelatedSkill(emo__chixie_prohibit)

moe__huanhong:addSkill(emo__chixie)


Fk:loadTranslationTable{
  ["moe__huanhong"] = "焕鸿",
  
  ["emo__qingmu"] = "倾慕",
  [":emo__qingmu"] = "锁定技，游戏开始时，你须选择一名其他角色，随机为你与其标记一种类型或花色，当你或其使用或打出符合牌时，令另一方摸一张相同类型或花色的牌，并改变标记。",
  ["@emo__qingmu"] = "倾慕",
  ["#emo__qingmu-choose"] = "倾慕：选择一名其他角色，你与其使用或打出特定牌时令对方摸牌",
  
  ["emo__chixie"] = "执携",
  [":emo__chixie"] = "限定技，当你的“倾慕”目标进入濒死状态时，你可以令其回复体力值至与你相同，且本回合不为伤害牌的合法目标。",
  ["@@emo__chixie-turn"] = "被执携",
  ["#emo__chixie-invoke"] = "执携：你可以令 %src 回复体力值至与你相同！",

  ["$emo__chixie1"] = "",
  ["$emo__chixie2"] = "",
}

local moe__hejing = General(extension, "moe__hejing", "moe", 3, 3, General.Female)

---@param target ServerPlayer
---@param player ServerPlayer
DoZuwang = function (target, player, mode)
  if target.dead or player.dead then return end
  local room = player.room
  if type(mode) == "string" and mode == "emo__zuwang_put" then mode = 1 end
  if mode == 1 then
    target:drawCards(1, "emo__zuwang")
    if not (target.dead or player.dead or target:isNude()) then
      local card = room:askForCard(target, 1, 1, true, "emo__zuwang", false, ".", "#emo__zuwang_put")
      player:addToPile("ZWfamily", card, false, "emo__zuwang")
    end
  elseif #player:getPile("ZWfamily") > 0 then
    local cards = room:askForCardsChosen(target, player, 1, 1, {
    card_data = { { "ZWfamily", player:getPile("ZWfamily") }  } }, "emo__zuwang")
    local card = Fk:getCardById(cards[1])
    room:obtainCard(target, card, false)
    local get = room:getCardsFromPileByRule(".|.|"..card:getSuitString())
    if #get > 0 then
      room:moveCards({
      ids = get,
      fromArea = Card.DrawPile,
      to = target.id,
      toArea = Card.PlayerHand,
      moveReason = fk.ReasonPrey,
      skillName = "emo__zuwang",
      moveVisible = false,})
    end
  end
end

local emo__zuwang = fk.CreateTriggerSkill{
  name = "emo__zuwang",
  events = { fk.EventPhaseStart},
  anim_type = "support",
  derived_piles = "ZWfamily",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and ((target == player and player.phase == Player.Start ) 
    or (target:getMark("emo__zuwang_target") > 0 and target.phase == Player.Play ))
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if player.phase == Player.Start then 
      local tos = room:askForChoosePlayers(player, table.map(room.alive_players, Util.IdMapper), 1, 99, "#emo__zuwang-target", self.name, true)
      if #tos > 0 then
        self.cost_data = tos
        return true
      end
    else
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if player.phase == Player.Start then 
      for _, p in ipairs(table.map(self.cost_data, Util.Id2PlayerMapper)) do
        room:addPlayerMark(p, "emo__zuwang_target")
      end
    else
      room:setPlayerMark(target, "emo__zuwang_target", 0)
      local choies = {"emo__zuwang_put"}
      if #player:getPile("ZWfamily") > 0 then
        table.insert(choies, "emo__zuwang_get")
      end
      local choice = room:askForChoice(target, choies, self.name)
      DoZuwang (target, player, choice)
    end
  end,
}
moe__hejing:addSkill(emo__zuwang)


local emo__kefa = fk.CreateTriggerSkill{
  name = "emo__kefa",
  events = { fk.TargetConfirmed , fk.Damaged},
  anim_type = "support",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and target:isAlive() then
      if event == fk.TargetConfirmed then
        return data.card.type == Card.TypeTrick and #player:getPile("ZWfamily") < 3
      else
        return #player:getPile("ZWfamily") >= 3
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, nil, "#emo__kefa-invoke::"..target.id..":emo__zuwang_"..
    (event == fk.TargetConfirmed and "put" or "get"))
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.TargetConfirmed then
      DoZuwang (target, player, 1)
    else
      DoZuwang (target, player, 2)
    end
  end,
}

moe__hejing:addSkill(emo__kefa)

Fk:loadTranslationTable{
  ["moe__hejing"] = "何静",
  ["#moe__hejing"] = "当家闺秀",

  ["emo__zuwang"] = "族望",
  [":emo__zuwang"] = "准备阶段开始时，你可以令任意名角色于其下一个出牌阶段开始时选一项：<br>"..
  "①摸一张牌，然后将一张牌扣置你武将牌上称为“族”。<br>"..
  "②观看“族”并获得其中一张，然后摸一张与之花色相同的牌。",
  ["ZWfamily"] = "族",
  ["emo__zuwang_put"] = "摸一张牌，再将一张牌置入“族”中",
  ["emo__zuwang_get"] = "获得一张“族”，再摸一张同花色牌",
  ["#emo__zuwang-target"] = "对任意数量的角色发动“族望”",
  ["emo__zuwang_target"] = "族望",
  ["#emo__zuwang_put"] = "请将一张牌置入“族”中",

  ["emo__kefa"] = "苛法",
  [":emo__kefa"] = "每当一名角色成为锦囊牌的目标后，若“族”数小于3，你可令其执行〖族望〗①。每当一名角色受到伤害后，若“族”数不小于3，你可令其执行〖族望〗②。",
  ["#emo__kefa-invoke"] = "苛法：你可令 %dest 执行：%arg",
}

local moe__liruobing = General(extension, "moe__liruobing", "moe", 3, 3, General.Female)


local emo__yujie = fk.CreateTriggerSkill{
  name = "emo__yujie",
  events = { fk.EventPhaseStart , fk.DrawNCards},
  anim_type = "support",
  can_trigger = function(self, event, target, player, data)
    if event == fk.EventPhaseStart then
      return player:hasSkill(self) and target == player and player.phase == Player.Start and not player:isNude()
    else
      return player:hasSkill(self) and target == player and player:getMark("@emo__yujie") > 0
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if event == fk.EventPhaseStart then
      return #room:askForDiscard(player, 1, 1, true, self.name, true, ".|.|.|.|.|trick,equip" , "#emo__yujie-invoke") > 0
    else
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.EventPhaseStart then
      local mark = type(player:getMark("emo__yujie")) == "table" and player:getMark("emo__yujie") or {0,0}
      for i = 1, 2 do
        mark[i] = mark[i] + 1
      end
      room:setPlayerMark(player, "emo__yujie", mark)
      room:setPlayerMark(player, "@emo__yujie", mark[1])
    else
      data.n = data.n + player:getMark("@emo__yujie")
    end
  end,

  refresh_events = {fk.TurnEnd},
  can_refresh = function(self, event, target, player, data)
    return target == player and type(player:getMark("emo__yujie")) == "table"
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    local mark = player:getMark("emo__yujie")
    local new_mark = {mark[2], 0}
    room:setPlayerMark(player, "emo__yujie", new_mark)
    room:setPlayerMark(player, "@emo__yujie", new_mark[1])
  end,
}

local emo__yujie_maxcards = fk.CreateMaxCardsSkill{
  name = "#emo__yujie_maxcards",
  correct_func = function(self, player)
    return player:hasSkill("emo__yujie") and player:getMark("@emo__yujie") or 0
  end,
}
emo__yujie:addRelatedSkill(emo__yujie_maxcards)

moe__liruobing:addSkill(emo__yujie)

local emo__tianxin = fk.CreateTriggerSkill{
  name = "emo__tianxin",
  anim_type = "control",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target == player and player.phase == Player.Finish
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, data)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local ids = room:getNCards(3)
    while #ids > 0 and not player.dead do
      local use = U.askForUseRealCard(room, player, ids, nil, self.name, nil, {expand_pile = ids}, true)
      if not use then break end
      table.removeOne(ids, use.card:getEffectiveId())
      room:useCard(use)
      ids = table.filter(ids, function(id) return table.contains(room.draw_pile, id) end)
    end
  end,
}

moe__liruobing:addSkill(emo__tianxin)

Fk:loadTranslationTable{
  ["moe__liruobing"] = "黎若冰",

  ["emo__yujie"] = "玉洁",
  [":emo__yujie"] = "准备阶段开始时，你可以弃置一张非基本牌，令你本回合和下个回合内：摸牌阶段摸牌基数+1，手牌上限+1。",
  ["@emo__yujie"] = "玉洁",
  ["#emo__yujie-invoke"] = "玉洁：你可弃一张非基本牌，本回合和下个回合内：摸牌阶段摸牌+1，手牌上限+1",

  ["emo__tianxin"] = "天歆",
  [":emo__tianxin"] = "结束阶段开始时，你可以观看牌堆顶三张牌并使用其中任意张牌。",
}

local moe__duling = General(extension, "moe__duling", "moe", 3, 3, General.Female)

local emo__liuke = fk.CreateViewAsSkill{
  name = "emo__liuke",
  pattern = ".|.|.|.|.|basic",
  prompt = "#emo__liuke",
  interaction = function(self)
    local names = U.getViewAsCardNames(Self, self.name, Self:getTableMark("@$emo__liuke-round"))
    if #names > 0 then
      return UI.ComboBox { choices = names }
    end
  end,
  card_num = 0,
  card_filter = Util.FalseFunc,
  view_as = function(self)
    if not self.interaction.data then return end
    local card = Fk:cloneCard(self.interaction.data)
    card.skillName = self.name
    return card
  end,
  before_use = function(self, player, use)
    player.room:removeTableMark(player, "@$emo__liuke-round", use.card.name)
  end,
  enabled_at_play = function(self, player)
    return player:getMark("@$emo__liuke-round") ~= 0
  end,
  enabled_at_response = function(self, player, response)
    if Fk.currentResponsePattern then
      local mark = player:getTableMark("@$emo__liuke-round")
      for _, n in ipairs(mark) do
        local card = Fk:cloneCard(n)
        if Exppattern:Parse(Fk.currentResponsePattern):matchExp(card.trueName) then
          return true
        end
      end
    end
  end,
}

local emo__liuke_trigger = fk.CreateTriggerSkill{
  name = "#emo__liuke_trigger",
  mute = true,
  main_skill = emo__liuke,
  events = {fk.RoundStart, fk.RoundEnd, fk.CardUsing, fk.CardResponding},
  can_trigger = function(self, event, target, player, data)
    if event == fk.RoundStart then
      return player:hasSkill(emo__liuke)
    elseif event == fk.RoundEnd then
      return player:getMark("@$emo__liuke-round") ~= 0
    else
      return target == player and player:hasSkill(emo__liuke) and table.contains(data.card.skillNames, "emo__liuke")
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local skillName = "emo__liuke"
    if event == fk.RoundStart then
      room:notifySkillInvoked(player, skillName, "drawcard")
      local all_choices = U.getAllCardNames("b")
      local choices = table.simpleClone(all_choices)
      local names = {}
      for i = 1, 4 do
        local name = room:askForChoice(player, choices, skillName, "#emo__liuke-choice:::"..i, false, all_choices)
        table.insert(names, name)
        if name ~= "slash" and name ~= "jink" then
          table.removeOne(choices, name)
        end
        room:addTableMark(player, "@$emo__liuke-round", name)
      end
    elseif event == fk.RoundEnd then
      room:notifySkillInvoked(player, skillName, "negative")
      local num = #player:getTableMark("@$emo__liuke-round")
      room:askForDiscard(player, num, num, true, skillName, false)
    else
      player:drawCards(1, skillName)
    end
  end,
}
emo__liuke:addRelatedSkill(emo__liuke_trigger)

moe__duling:addSkill(emo__liuke)

Fk:loadTranslationTable{
  ["moe__duling"] = "杜泠",
  ["#moe__duling"] = "孤高游侠",

  ["emo__liuke"] = "流客",
  [":emo__liuke"] = "每轮开始时，你记录4张基本牌（除【杀】、【闪】外每种限一次），本轮中你可视为使用或打出这些牌，移去记录并摸一张牌。本轮结束时，每有一张记录的牌，你须弃置一张牌。",
  ["#emo__liuke_trigger"] = "流客",
  ["@$emo__liuke-round"] = "流客",
  ["#emo__liuke"] = "流客：你可以使用或打出记录的基本牌",
  ["#emo__liuke-choice"] = "流客：请选择本轮你可以视为使用或打出的牌名（第 %arg 张，共4张）",
}

local moe__luyujing = General(extension, "moe__luyujing", "moe", 3, 3, General.Female)

local emo__runyu = fk.CreateTriggerSkill{
  name = "emo__runyu",
  anim_type = "drawcard",
  events = {fk.CardUsing},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target == player and data.extra_data and data.extra_data.emo__runyuDraw
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local num = data.extra_data.emo__runyuDraw
    if data.card.type == Card.TypeBasic then
      if room:askForSkillInvoke(player, self.name, nil, "#emo__runyu-draw:::"..num) then
        self.cost_data = {tos = {player.id}}
        return true
      end
    else
      local tos = room:askForChoosePlayers(player, table.map(room:getOtherPlayers(player, false), Util.IdMapper),
      1, 1, "#emo__runyu-choose:::"..num, self.name, true)
      if #tos > 0 then
        self.cost_data = {tos = tos}
        return true
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(self.cost_data.tos[1])
    to:drawCards(data.extra_data.emo__runyuDraw, self.name)
  end,

  refresh_events = {fk.EventAcquireSkill, fk.EventLoseSkill, fk.CardUsing, fk.RoundStart},
  can_refresh = function(self, event, target, player, data)
    if event == fk.CardUsing then
      return player == target and player:hasSkill(self, true)
      and player:getMark("@emo__runyu_basic") ~= 0 and player:getMark("@emo__runyu_nonbasic") ~= 0
    elseif event == fk.RoundStart then
      return player:hasSkill(self, true)
    else
      return player == target and data == self
    end
  end,
  on_refresh = function (self, event, target, player, data)
    local room = player.room
    if event == fk.EventLoseSkill then
      room:setPlayerMark(player, "@emo__runyu_basic", 0)
      room:setPlayerMark(player, "@emo__runyu_nonbasic", 0)
    else
      local basic, nonbasic = {0, 0}, {0, 0}
      if event == fk.EventAcquireSkill then
        local parentRound = room.logic:getCurrentEvent():findParent(GameEvent.Round)
        if parentRound then
          room.logic:getEventsByRule(GameEvent.UseCard, 1, function (e)
            local use = e.data[1]
            if use.from == player.id then
              if use.card.type == Card.TypeBasic then
                basic[1] = basic[1] + 1
                nonbasic[2] = nonbasic[2] + 1
              else
                nonbasic[1] = nonbasic[1] + 1
                if basic[2] == 0 then
                  basic[2] = Fk:translate(use.card.trueName, "zh_CN"):len()
                end
              end
            end
            return false
          end, parentRound.id)
        end
      elseif event == fk.CardUsing then
        data.extra_data = data.extra_data or {}
        basic = table.map(player:getMark("@emo__runyu_basic"):split("/"), function(s) return tonumber(s) end)
        nonbasic = table.map(player:getMark("@emo__runyu_nonbasic"):split("/"), function(s) return tonumber(s) end)
        if data.card.type == Card.TypeBasic then
          basic[1] = basic[1] + 1
          nonbasic[2] = nonbasic[2] + 1
          if basic[1] == basic[2] then
            data.extra_data.emo__runyuDraw = basic[1]
          end
        else
          nonbasic[1] = nonbasic[1] + 1
          basic[2] = Fk:translate(data.card.trueName, "zh_CN"):len()
          if nonbasic[1] == nonbasic[2] then
            data.extra_data.emo__runyuDraw = nonbasic[1]
          end
        end
      end
      room:setPlayerMark(player, "@emo__runyu_basic", table.concat(basic, "/"))
      room:setPlayerMark(player, "@emo__runyu_nonbasic", table.concat(nonbasic, "/"))
    end
  end
}
moe__luyujing:addSkill(emo__runyu)

local emo__rongyong = fk.CreateViewAsSkill{
  name = "emo__rongyong",
  anim_type = "control",
  pattern = "enemy_at_the_gates",
  prompt = "#emo__rongyong",
  card_filter = Util.FalseFunc,
  view_as = function(self, cards)
    local c = Fk:cloneCard("enemy_at_the_gates")
    c.skillName = self.name
    c:addSubcards(Self:getCardIds("h"))
    return c
  end,
  enabled_at_play = function(self, player)
    return not player:isKongcheng() and player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  enabled_at_response = function (self, player, response)
    return false
  end,
}

local emo__rongyong_trigger = fk.CreateTriggerSkill{
  name = "#emo__rongyong_trigger",
  mute = true,
  events = {fk.AfterCardsMove},
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(emo__rongyong) then return false end
    local parentEvent = player.room.logic:getCurrentEvent().parent
    if parentEvent and parentEvent.event == GameEvent.SkillEffect then
      parentEvent = parentEvent.parent
      if parentEvent and parentEvent.event == GameEvent.CardEffect then
        local effect = parentEvent.data[1]
        if effect.from == player.id and effect.card.name == "enemy_at_the_gates"
        and table.contains(effect.card.skillNames, "emo__rongyong") then
          for _, move in ipairs(data) do
            if move.toArea == Card.Processing then
              for _, info in ipairs(move.moveInfo) do
                if player.room:getCardArea(info.cardId) == Card.Processing and Fk:getCardById(info.cardId).trueName ~= "slash" then
                  self.cost_data = info.cardId
                  return true
                end
              end
            end
          end
        end
      end
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:delay(300)
    room:obtainCard(player, self.cost_data, true, fk.ReasonJustMove, player.id, self.name)
  end,
}
emo__rongyong:addRelatedSkill(emo__rongyong_trigger)

moe__luyujing:addSkill(emo__rongyong)

Fk:loadTranslationTable{
  ["moe__luyujing"] = "陆玉静",

  ["emo__runyu"] = "润玉",
  [":emo__runyu"] = "每当你使用每轮第X张基本牌时，你可以摸X张牌（X为本轮你使用上一张非基本牌的牌名字数）；"..
  "<br>每当你使用每轮第Y张非基本牌时，你可以令一名其他角色摸Y张牌（Y为本轮你使用基本牌数）。",
  ["#emo__runyu-draw"] = "威羽：你可以摸 %arg 张牌",
  ["#emo__runyu-choose"] = "威羽：你可以令一名其他角色摸 %arg 张牌",
  ["@emo__runyu_basic"] = "润玉基本",
  ["@emo__runyu_nonbasic"] = "润玉非基",

  ["emo__rongyong"] = "荣雍",
  [":emo__rongyong"] = "出牌阶段限一次，你可以将所有手牌当【兵临城下】使用，并获得因此牌亮出的非【杀】牌。",
  ["#emo__rongyong"] = "荣雍：将所有手牌当【兵临城下】使用，并获得亮出的非【杀】牌",
  ["#emo__rongyong_trigger"] = "荣雍",
}

local moe__huangxueer = General(extension, "moe__huangxueer", "moe", 3, 3, General.Female)

local emo__jiujue = fk.CreateTriggerSkill{
  name = "emo__jiujue",
  events = {fk.Damaged},
  anim_type = "masochism",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and not player:isKongcheng()
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local cardIds = {} 
    for _, cid in ipairs(player:getCardIds("h")) do
      local card = Fk:getCardById(cid)
      if player:canUse(card) then table.insert(cardIds, cid) end
    end
    if #cardIds == 0 then return false end
    local use = U.askForUseRealCard(room, player, nil, ".", self.name, "#emo__jiujue-ask", nil, true)
    if use then
      self.cost_data = use
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local use = self.cost_data
    room:useCard(use)
    if not player.dead then
      player:drawCards(1, self.name)
    end
    
    if player.dead or player:isKongcheng() then return false end
    local color = use.card:getColorString()
    local pattern = "."
    if color == "red" then
      pattern = ".|.|spade,club"
    elseif color == "Black" then
      pattern = ".|.|heart,diamond"
    end
    local new_use = U.askForUseRealCard(room, player, nil, pattern, self.name, "#emo__jiujue-other:::"..color)
    if new_use and not player.dead then
      player:drawCards(2, self.name)
    end
  end,
}
moe__huangxueer:addSkill(emo__jiujue)

local emo__zhumo = fk.CreateActiveSkill{
  name = "emo__zhumo",
  anim_type = "offensive",
  min_card_num = 1,
  target_num = 0,
  can_use = function(self, player)
    return not player:isKongcheng()
  end,
  card_filter = function(self, to_select, selected)
    if Fk:currentRoom():getCardArea(to_select) == Player.Equip then return false end
    local n = Fk:getCardById(to_select).number
    for _, id in ipairs(selected) do
      n = n + Fk:getCardById(id).number
    end
    return n <= 13
  end,
  feasible = function(self, selected, selected_cards)
    local n = 0 
    for _, id in ipairs(selected_cards) do
      n = n + Fk:getCardById(id).number
    end
    return #selected == 0 and n == 13
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    room:throwCard(effect.cards, self.name, player, player)
    if not player.dead then
      player:drawCards(1, self.name)
    end
    for _, p in ipairs(room:getAlivePlayers()) do
      if not p.dead then
        room:loseHp(p, 1, self.name)
      end
    end
  end,
}
moe__huangxueer:addSkill(emo__zhumo)


Fk:loadTranslationTable{
  ["moe__huangxueer"] = "黄雪儿",

  ["emo__jiujue"] = "久绝",
  [":emo__jiujue"] = "每当你受到伤害后，你可以使用一张手牌并摸一张牌，然后可以使用一张与之颜色不同的手牌并摸两张牌。",
  ["#emo__jiujue-ask"] = "久绝：你可以使用一张手牌，并摸一张牌",
  ["#emo__jiujue-other"] = "久绝：你可以使用一张非%arg手牌，并摸两张牌",

  ["emo__zhumo"] = "珠没",
  [":emo__zhumo"] = "出牌阶段，你可以弃置点数之和为13的手牌，摸一张牌然后令所有角色依次失去一点体力。",
}

local moe__yanpinting = General(extension, "moe__yanpinting", "moe", 4, 4, General.Female)

local emo__liuping = fk.CreateTriggerSkill{
  name = "emo__liuping",
  anim_type = "control",
  frequency = Skill.Compulsory,
  events = {fk.GameStart},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) 
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local roles = {}
    for _, p in ipairs(room.players) do
      table.insertIfNeed(roles, p.role)
    end
    local role = room:askForChoice(player, roles, self.name)
    local mark = room:getTag("emo__liuping_role") or {}
    local choice = room:askForChoice(player, {"loseHp" , "draw2"}, self.name, "#emo__liuping-choice:::"..role)
    local rule = mark[role] or {}
    table.insert(rule, choice)
    mark[role] = rule
    room:setTag("emo__liuping_role", mark)
  end,
}

local emo__liuping_delay = fk.CreateTriggerSkill{
  name = "#emo__liuping_delay",
  mute = true,
  frequency = Skill.Compulsory,
  events = {fk.Deathed},
  can_trigger = function(self, event, target, player, data)
    -- 休整不会触发
    if player.dead or target.rest > 0 then return false end
    local mark = player.room:getTag("emo__liuping_role")
    if type(mark) ~= "table" or not mark[target.role] then return false end
    return data.damage and data.damage.from and data.damage.from == player
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local mark = room:getTag("emo__liuping_role")
    room:sendLog{ type = "#emo__liuping_DelayInvoked", arg = "emo__liuping", from = player.id }
    for _, m in ipairs(mark[target.role]) do
      if player.dead then break end
      if m == "loseHp" then
        room:loseHp(player, 1, self.name)
      else
        player:drawCards(2, self.name)
      end
    end
  end,
}
emo__liuping:addRelatedSkill(emo__liuping_delay)

local emo__liuping_maxcards = fk.CreateMaxCardsSkill{
  name = "#emo__liuping_maxcards",
  correct_func = function(self, player)
    return player:hasSkill("emo__liuping") and 3 * player:getLostHp() or 0
  end,
}
emo__liuping:addRelatedSkill(emo__liuping_maxcards)

moe__yanpinting:addSkill(emo__liuping)


local emo__liufang = fk.CreateTriggerSkill{
  name = "emo__liufang",
  events = {fk.AfterCardsMove},
  frequency = Skill.Compulsory,
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and player:usedSkillTimes(self.name, Player.HistoryTurn) == 0 and player.phase == Player.NotActive then
      -- 寻找真实发动的主技能
      local e = player.room.logic:getCurrentEvent().parent
      if e and e.event == GameEvent.SkillEffect then
        local _skill = e.data[3]
        local skill = _skill.main_skill and _skill.main_skill or _skill
        if skill.name:startsWith("#") then
          -- 暴力搜主技能……
          for _, s in pairs(Fk.skills) do
            if table.contains(s.related_skills, skill) then
              skill = s
              break
            end
          end
        end
        if skill.visible and not player:hasSkill(skill, true) then
          for _, move in ipairs(data) do
            if move.to and move.to ~= player.id and move.toArea == Card.PlayerHand then
              local owner = player.room:getPlayerById(move.to)
              if owner:hasSkill(skill, true) and skill:isPlayerSkill(owner) then
                self.cost_data = {choice = skill.name, tos = {move.to}}
                return true
              end
            end
          end
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local choice = self.cost_data.choice
    room:addTableMark(player, "@[:]emo__liufang_skill", choice)
    room:handleAddLoseSkills(player, choice)
  end,
}

local emo__liufang_delay = fk.CreateTriggerSkill{
  name = "#emo__liufang_delay",
  events = {fk.TurnEnd},
  priority = 0.99,
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return target == player and player:getMark("@[:]emo__liufang_skill") ~= 0
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local skills = player:getMark("@[:]emo__liufang_skill")
    room:setPlayerMark(player, "@[:]emo__liufang_skill", 0)
    room:handleAddLoseSkills(player, "-"..table.concat(skills, "|-"))
  end,
}
emo__liufang:addRelatedSkill(emo__liufang_delay)
moe__yanpinting:addSkill(emo__liufang)

Fk:loadTranslationTable{
  ["moe__yanpinting"] = "闫娉婷",
  ["#moe__yanpinting"] = "乱世游萍",

  ["emo__liuping"] = "流萍",
  ["#emo__liuping_delay"] = "流萍",
  [":emo__liuping"] = "锁定技，游戏开始时，你秘密选择一种身份，令杀死该身份的角色失去一点体力或摸两张牌。你的手牌上限+3X（X为你已损失体力值）。",
  ["#emo__liuping-choice"] = "本局游戏内，令杀死 %arg 的角色失去一点体力或摸两张牌",
  ["#emo__liuping_DelayInvoked"] = "%from 触发了〖%arg〗的延迟效果",

  ["emo__liufang"] = "留芳",
  [":emo__liufang"] = "锁定技，每回合限一次，你的回合外，当一名其他角色因其拥有的技能的效果而获得牌时，你获得此技能直到你回合结束。",
  ["#emo__liufang_delay"] = "留芳",
  ["@[:]emo__liufang_skill"] = "留芳",
}


local moe__yangxiaodi = General(extension, "moe__yangxiaodi", "moe", 4, 4, General.Female)

local emo__andi = fk.CreateTriggerSkill{
  name = "emo__andi",
  events = {fk.GameStart, fk.CardUseFinished},
  anim_type = "control",
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) then return false end
    if event == fk.GameStart then return true end
    return table.contains(player:getTableMark("@$emo__andi"), data.card.name)
    and not table.contains(player:getTableMark("emo__andi_invoked-turn"), data.card.name)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.GameStart then
      local mark = player:getTableMark("@$emo__andi")
      local trick_num = 0
      local all_names = {}
      -- 衍生牌也记录
      for name, card in pairs(Fk.all_card_types) do
        if card.type == Card.TypeTrick then
          table.insert(all_names, name)
        end
      end
      for _, p in ipairs(room.alive_players) do
        for _, s in ipairs(p.player_skills) do
          if not (s:isEquipmentSkill(p) or s.name[#s.name] == "&") then
            local str = Fk:translate(":"..s.name)
            local names = table.filter(all_names, function (name)
              return string.find(str, Fk:translate(name))
            end)
            if #names > 0 then
              table.insertTableIfNeed(mark, names)
            elseif string.find(str, Fk:translate("trick")) then
              trick_num = trick_num + 1
            end
          end
        end
      end
      local rest_names = table.filter(U.getAllCardNames("td"), function(name) return not table.contains(mark, name) end)
      if #rest_names > 0 and trick_num > 0 then
        table.insertTable(mark, table.random(rest_names, trick_num))
      end
      room:setPlayerMark(player, "@$emo__andi", #mark > 0 and mark or 0)
    else
      room:addTableMark(player, "emo__andi_invoked-turn", data.card.name)
      if #room:getOtherPlayers(player, false) == 0 then return end
      local tos = room:askForChoosePlayers(player, table.map(room:getOtherPlayers(player), Util.IdMapper), 1, 1, "#emo__andi-choose", self.name, false)
      if #tos > 0 then
        local to = room:getPlayerById(tos[1])
        room:addPlayerMark(to, MarkEnum.UncompulsoryInvalidity.."-turn")
        room:setPlayerMark(to, "@@emo__andi-turn", 1)
        room:damage { from = player, to = to, damage = 1, skillName = self.name }
      end
    end
  end,

  refresh_events = {fk.EventLoseSkill},
  can_refresh = function(self, event, target, player, data)
    return target == player and data == self
  end,
  on_refresh = function (self, event, target, player, data)
    player.room:setPlayerMark(player, "@$emo__andi", 0)
  end,
}
moe__yangxiaodi:addSkill(emo__andi)

local emo__bingying = fk.CreateTriggerSkill{
  name = "emo__bingying",
  anim_type = "drawcard",
  derived_piles = "emo__bingying",
  events = {fk.EventPhaseChanging},
  can_trigger = function (self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.to == Player.Draw and not player:isKongcheng()
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(player, "emo__bingying-phase", 1)
    local cards = player:getCardIds("h")
    player:addToPile(self.name, cards, false, self.name)
    if player.dead then return false end
    player:drawCards(#cards, self.name)
    data.to = Player.Play
  end,
}

local emo__bingying_delay = fk.CreateTriggerSkill{
  name = "#emo__bingying_delay",
  events = {fk.EventPhaseEnd},
  mute = true,
  can_trigger = function (self, event, target, player, data)
    return target == player and player:getMark("emo__bingying-phase") > 0
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(player, "emo__bingying-phase", 0)
    player:throwAllCards("h")
    local cards = player:getPile("emo__bingying")
    if #cards  > 0 then
      room:obtainCard(player, cards, false, fk.ReasonPrey, player.id, self.name)
    end
  end,
}

emo__bingying:addRelatedSkill(emo__bingying_delay)

moe__yangxiaodi:addSkill(emo__bingying)

Fk:loadTranslationTable{
  ["moe__yangxiaodi"] = "杨小笛",
  
  ["emo__andi"] = "暗笛",
  [":emo__andi"] = "锁定技，游戏开始时，你记录所有角色技能描述中出现的锦囊牌牌名，若技能描述含有“锦囊牌”，记录随机锦囊牌牌名。"..
  "<br>每回合每牌名限一次，当任意角色使用你记录的牌名后，你对一名其他角色造成1点伤害并令其本回合非锁定技失效。",
  ["@$emo__andi"] = "暗笛",
  ["#emo__andi-choose"] = "暗笛:对一名其他角色造成1点伤害并令其本回合非锁定技失效",
  ["@@emo__andi-turn"] = "暗笛:封技",

  ["emo__bingying"] = "冰颖",
  [":emo__bingying"] = "摸牌阶段开始前，你可以将所有手牌扣置于武将牌上，若如此做，你摸等量的牌，此阶段改为出牌阶段，且此阶段结束时，你弃置所有手牌并获得武将牌上的牌。",
  ["#emo__bingying_delay"] = "冰颖",
}
--[[
local moe__nangongtao = General(extension, "moe__nangongtao", "moe", 4, 4, General.Female)

local emo__ziai = fk.CreateTriggerSkill{
  name = "emo__ziai",
  frequency = Skill.Compulsory,
  anim_type = "drawcard",
  events = {fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and (target.gender == General.Female or target.gender == General.Bigender) then
      local events = player.room.logic:getEventsOfScope(GameEvent.UseCard, 1, function (e)
        return e.data[1].card.color == data.card.color
      end, Player.HistoryTurn)
      return #events > 0 and events[1].data[1] == data
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:drawCards(1, self.name)
    if player.dead then return end
    for pid, _ in pairs(data.damageDealt or {}) do
      if pid ~= player.id then
        room:loseHp(player, 1, self.name)
        break
      end
    end
  end,
}
moe__nangongtao:addSkill(emo__ziai)

Fk:loadTranslationTable{
  ["moe__nangongtao"] = "南宫桃",

  ["emo__ziai"] = "姊爱",
  [":emo__ziai"] = "锁定技，每回合每种颜色第一张被使用的牌结算结束后，若使用者为女性，你摸一张牌，然后若此牌对你以外的角色造成了伤害，你失去1点体力。",
}
--]]

local moe__changle = General(extension, "moe__changle", "moe", 3, 3, General.Female)

local emo__huiju = fk.CreateTriggerSkill{
  name = "emo__huiju",
  anim_type = "defensive",
  events = {fk.DamageInflicted},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target == player and data.from and not player:inMyAttackRange(data.from)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if data.card then
      local subcards = data.card:isVirtual() and data.card.subcards or {data.card.id}
      if #subcards > 0 and table.every(subcards, function(id) return room:getCardArea(id) == Card.Processing end) then
        room:obtainCard(player, data.card, true, fk.ReasonJustMove)
      end
    end
    room:addPlayerMark(data.from, "emo__huiju_target-round")
    data.damage = 0
    return true
  end
}
local emo__huiju_distance = fk.CreateDistanceSkill{
  name = "#emo__huiju_distance",
  correct_func = function() return 0 end,
  fixed_func = function(self, from, to)
    if from:hasSkill(self) and to:getMark("emo__huiju_target-round") > 0 then
      return 1
    end
  end,
}
emo__huiju:addRelatedSkill(emo__huiju_distance)
moe__changle:addSkill(emo__huiju)

local emo__huichun = fk.CreateTriggerSkill{
  name = "emo__huichun",
  events = {fk.AskForPeaches},
  anim_type = "defensive",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and player:getMark("@emo__huichun") >= 3 and player == target
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, nil, "#emo__huichun-invoke:"..data.who)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:removePlayerMark(player, "@emo__huichun", 3)
    room:recover { num = 3, skillName = self.name, who = room:getPlayerById(data.who), recoverBy = player} 
  end,

  refresh_events = {fk.HpRecover},
  can_refresh = function(self, event, target, player, data)
    return player:hasSkill(self, true) and (player == target or data.recoverBy == player) and not data.skillName == self.name
  end,
  on_refresh = function(self, event, target, player, data)
    player.room:addPlayerMark(player, "@emo__huichun", data.num)
  end
}

moe__changle:addSkill(emo__huichun)

local emo__shoucheng = fk.CreateTriggerSkill{
  name = "emo__shoucheng",
  events = {fk.TurnStart},
  frequency = Skill.Limited,
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and player == target and player:usedSkillTimes(self.name, Player.HistoryGame) == 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(player, "@@emo__shoucheng-turn", 1)
    player:drawCards(3, self.name)
  end,
}

local emo__shoucheng_delay = fk.CreateTriggerSkill{
  name = "#emo__shoucheng_delay",
  events = {fk.TurnEnd},
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return not player.dead and player == target and player:getMark("@@emo__shoucheng-turn") > 0
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local ids = {}
    room.logic:getEventsOfScope(GameEvent.MoveCards, 1, function(e)
      for _, move in ipairs(e.data) do
        if move.toArea == Card.DiscardPile and move.moveReason ~= fk.ReasonUse then
          for _, info in ipairs(move.moveInfo) do
            if room:getCardArea(info.cardId) == Card.DiscardPile then
              table.insertIfNeed(ids, info.cardId)
            end
          end
        end
      end
      return false
    end, Player.HistoryTurn)
    if #ids > 0 then
      room:obtainCard(player, ids, false, fk.ReasonPrey)
    end
  end,
}
emo__shoucheng:addRelatedSkill(emo__shoucheng_delay)

moe__changle:addSkill(emo__shoucheng)

Fk:loadTranslationTable{
  ["moe__changle"] = "长乐",

  ["emo__huiju"] = "晦居",
  [":emo__huiju"] = "锁定技，每当你攻击范围外的一名其他角色对你造成伤害时，防止此伤害，你获得伤害牌，然后与其距离为1直到本轮结束。",

  ["emo__huichun"] = "回春",
  [":emo__huichun"] = "每当你不以此法回复体力后，或你不以此法令其他角色恢复体力后，你获得等量“回春”标记。每当一名角色处于濒死状态时，你可以移除3枚“回春”标记，若如此做，其回复3点体力。",
  ["@emo__huichun"] = "回春",
  ["#emo__huichun-invoke"] = "回春：你可以移除3枚“回春”标记，令%src回复3点体力",

  ["emo__shoucheng"] = "守成",
  [":emo__shoucheng"] = "限定技，回合开始时，你可以摸三张牌，若如此做，回合结束时，你获得本回合不因使用进入弃牌堆的牌。",
  ["#emo__shoucheng_delay"] = "守成",
  ["@@emo__shoucheng-turn"] = "守成",

  ["$emo__shoucheng1"] = "祖宗之法不可变",
  ["$emo__shoucheng2"] = "古史为鉴，族法为训",
}

local moe__xuxiao = General(extension, "moe__xuxiao", "moe", 3, 3, General.Female)

local emo__meimu = fk.CreateActiveSkill{
  name = "emo__meimu",
  anim_type = "control",
  card_num = 0,
  target_num = 1,
  card_filter = Util.FalseFunc,
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) < 1 
  end,
  target_filter = function(self, to_select, selected, selected_cards)
    return #selected == 0 and Self.id ~= to_select and not Fk:currentRoom():getPlayerById(to_select):isKongcheng()
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    local ids = target:getCardIds("h")
    room:setPlayerMark(player, "emo__meimu_cards", ids)
    room:setPlayerMark(player, "emo__meimu_from", target.id)
    local _, dat = room:askForUseActiveSkill(player, "emo__meimu_viewas", "#emo__meimu-use:"..target.id, true, {expand_pile = ids}, true)
    if dat then
      local card = Fk:getCardById(dat.cards[1])
      local name = card.color == Card.Red and "fire_attack" or "dismantlement"
      local to_use = Fk:cloneCard(name)
      to_use:addSubcard(card)
      to_use.skillName = self.name
      room:useCard{
        extra_data = {emo__meimu_proposer = player.id},
        from = target.id,
        tos = table.map(dat.targets, function(p) return {p} end),
        card = to_use,
        extraUse = true,
      }
    end
  end,
}
local emo__meimu_viewas = fk.CreateActiveSkill{
  name = "emo__meimu_viewas",
  card_num = 1,
  min_target_num = 1,
  expand_pile = "emo__meimu",
  card_filter = function (self, to_select, selected)
    local card = Fk:getCardById(to_select)
    local cards = Self:getMark("emo__meimu_cards")
    local from = Fk:currentRoom():getPlayerById(Self:getMark("emo__meimu_from"))
    if #selected > 0 or card.color == Card.NoColor or not table.contains(cards, to_select) then return false end
    local name = card.color == Card.Red and "fire_attack" or "dismantlement"
    local to_use = Fk:cloneCard(name)
    to_use:addSubcard(to_select)
    return not from:prohibitUse(to_use)
  end,
  target_filter = function (self, to_select, selected, selected_cards)
    if #selected_cards ~= 1 then return false end
    local from = Fk:currentRoom():getPlayerById(Self:getMark("emo__meimu_from"))
    local name = Fk:getCardById(selected_cards[1]).color == Card.Red and "fire_attack" or "dismantlement"
    local to_use = Fk:cloneCard(name)
    to_use:addSubcard(selected_cards[1])
    local to = Fk:currentRoom():getPlayerById(to_select)
    return not from:isProhibited(to, to_use) and to_use.skill:modTargetFilter(to_select, selected, from, to_use)
    and #selected < to_use.skill:getMaxTargetNum(from, to_use)
  end,
}
Fk:addSkill(emo__meimu_viewas)

local emo__meimu_trigger = fk.CreateTriggerSkill{
  name = "#emo__meimu_trigger",
  mute = true,
  events = {fk.AfterCardsMove},
  can_trigger = function(self, event, target, player, data)
    local e = player.room.logic:getCurrentEvent():findParent(GameEvent.UseCard)
    if not e then return false end
    local use = e.data[1]
    return table.contains(use.card.skillNames, "emo__meimu") and use.extra_data and use.extra_data.emo__meimu_proposer == player.id and not player.dead
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    for _, move in ipairs(data) do
      if move.toArea == Card.DiscardPile and move.moveReason == fk.ReasonDiscard then
        for _, info in ipairs(move.moveInfo) do
          local card = Fk:getCardById(info.cardId)
          if card.type == Card.TypeBasic then
            player:setSkillUseHistory("emo__meimu", 0, Player.HistoryPhase)
          else
            player:drawCards(1, "emo__meimu")
          end
        end
      end
    end
  end,
}

emo__meimu:addRelatedSkill(emo__meimu_trigger)
moe__xuxiao:addSkill(emo__meimu)

local emo__niwang = fk.CreateTriggerSkill{
  name = "emo__niwang",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return player == target and player:hasSkill(self) and player.phase == Player.Draw
  end,
  on_cost = function(self, event, target, player, data)
    local tos = player.room:askForChoosePlayers(player, table.map(player.room:getOtherPlayers(player), Util.IdMapper), 1, 2, "#emo__niwang-choose", self.name, true)
    if #tos > 0 then
      self.cost_data = tos
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    for _, pid in ipairs(self.cost_data) do
      local p = room:getPlayerById(pid)
      if not p.dead then
        room:setPlayerMark(p, "@emo__niwang-turn", 3)
        p:drawCards(2, self.name)
      end
    end
    room:setPlayerMark(player, "emo__niwang-turn", 1)
    return true
  end,
}

local emo__niwang_delay = fk.CreateTriggerSkill{
  name = "#emo__niwang_delay",
  mute = true,
  events = {fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)
    if player == target and player:getMark("emo__niwang-turn") > 0 and not player.dead then
      local events = player.room.logic:getEventsOfScope(GameEvent.UseCard, 1, function (e)
        local use = e.data[1]
        return use and use.from == player.id and use.card.type == data.card.type
      end, Player.HistoryTurn)
      return #events > 0 and events[1].data[1] == data
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    for _, p in ipairs(room:getAlivePlayers()) do
      if p:getMark("@emo__niwang-turn") > 0 then
        room:removePlayerMark(p, "@emo__niwang-turn")
        if not p:isNude() and not player.dead then
          room:obtainCard(player, table.random(p:getCardIds("he")), false, fk.ReasonPrey)
        end
      end
    end
  end,
}
emo__niwang:addRelatedSkill(emo__niwang_delay)
moe__xuxiao:addSkill(emo__niwang)


Fk:loadTranslationTable{
  ["moe__xuxiao"] = "许潇",

  ["emo__meimu"] = "眉慕",
  [":emo__meimu"] = "出牌阶段限一次，你可以观看一名其他角色的手牌，然后你可以选择其中一张牌，令其将红色牌视为【火攻】、黑色牌视为【过河拆桥】对你选择的目标使用。若以此法弃置了：基本牌，此技能视为未发动；非基本牌，你摸一张牌。",
  ["emo__meimu_viewas"] = "眉慕",
  ["#emo__meimu-use"] = "眉慕：令 %src 将红色/黑色牌视为【火攻】/【过河拆桥】对你选择的目标使用",

  ["emo__niwang"] = "溺妄",
  [":emo__niwang"] = "摸牌阶段，你可以放弃摸牌，令一至两名其他角色各摸两张牌，若如此做，本回合你使用每种类型的第一张牌后，你获得这些角色各随机一张牌。",
  ["#emo__niwang-choose"] = "溺妄：放弃摸牌，令一至两名其他角色各摸两张牌",
  ["@emo__niwang-turn"] = "溺妄",
  ["#emo__niwang_delay"] = "溺妄",
}

local moe__bohe = General(extension, "moe__bohe", "moe", 4, 4, General.Female)

local emo__yongyi = fk.CreateActiveSkill{
  name = "emo__yongyi",
  anim_type = "support",
  min_card_num = 1,
  min_target_num = 1,
  prompt = "#emo__yongyi-prompt",
  card_filter = function(self, to_select, selected)
    return Fk:currentRoom():getCardArea(to_select) ~= Player.Equip
    and not Self:prohibitDiscard(Fk:getCardById(to_select))
    and #selected < #Fk:currentRoom().alive_players
  end,
  target_filter = function(self, to_select, selected, selected_cards)
    return #selected_cards > 0 and #selected < #selected_cards
    and Fk:currentRoom():getPlayerById(to_select):getMark("@@emo__yongyi") == 0
  end,
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  feasible = function(self, selected, selected_cards)
    return #selected >= 1 and #selected_cards == #selected
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    room:throwCard(effect.cards, self.name, player, player)
    room:sortPlayersByAction(effect.tos)
    for _, pid in ipairs(effect.tos) do
      local to = room:getPlayerById(pid)
      if not to.dead then
        room:setPlayerMark(to, "@@emo__yongyi", 1)
      end
    end
  end,
}

local emo__yongyi_delay = fk.CreateTriggerSkill{
  name = "#emo__yongyi_delay",
  mute = true,
  events = {fk.EventPhaseStart, fk.TargetSpecified, fk.CardEffectCancelledOut, fk.AfterCardUseDeclared, fk.CardUsing},
  can_trigger = function(self, event, target, player, data)
    if event == fk.EventPhaseStart then
      return target == player and player.phase == Player.Play and player:getMark("@@emo__yongyi") > 0
    end
    if target ~= player or data.card.trueName ~= "slash" then return false end
    local mark = player:getMark("@[:]emo__yongyi-phase")
    if mark == 0 then return false end
    mark = tonumber(string.sub(mark, #mark, #mark))
    if event == fk.TargetSpecified then
      return mark == 1
    elseif event == fk.CardEffectCancelledOut then
      return mark == 2
    elseif event == fk.AfterCardUseDeclared then
      return mark == 4 and data.card.name == "slash"
    elseif event == fk.CardUsing then
      return mark == 1 or mark == 4
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.EventPhaseStart then
      room:setPlayerMark(player, "@@emo__yongyi", 0)
      local num = math.random(4)
      room:setPlayerMark(player, "@[:]emo__yongyi-phase", "emo__yongyi_effect"..num)
      local ids = room:getCardsFromPileByRule("slash")
      if #ids > 0 then
        room:obtainCard(player, ids[1], false, fk.ReasonPrey)
      end
    elseif event == fk.TargetSpecified then
      data.fixedResponseTimes = data.fixedResponseTimes or {}
      data.fixedResponseTimes["jink"] = (data.fixedResponseTimes["jink"] or 1) + 1
    elseif event == fk.CardEffectCancelledOut then
      player:drawCards(1, "emo__yongyi")
    elseif event == fk.AfterCardUseDeclared then
      local card = Fk:cloneCard("fire__slash")
      card.skillName = "emo__yongyi"
      card:addSubcard(data.card)
      data.card = card
    elseif event == fk.CardUsing then
      if player:getMark("@[:]emo__yongyi-phase") == "emo__yongyi_effect1" then
        data.additionalDamage = (data.additionalDamage or 0) + 1
      else
        for _, pid in ipairs(TargetGroup:getRealTargets(data.tos)) do
          local to = room:getPlayerById(pid)
          if not to.dead then
            room:addPlayerMark(to, MarkEnum.UncompulsoryInvalidity .. "-turn")
          end
        end
      end
    end
  end,
}
emo__yongyi:addRelatedSkill(emo__yongyi_delay)

local emo__yongyi_targetmod = fk.CreateTargetModSkill{
  name = "#emo__yongyi_targetmod",
  bypass_distances = function(self, player, skill)
    return skill.trueName == "slash_skill" and player:getMark("@[:]emo__yongyi-phase") == "emo__yongyi_effect3"
  end,
  extra_target_func = function(self, player, skill)
    if skill.trueName == "slash_skill" and player:getMark("@[:]emo__yongyi-phase") == "emo__yongyi_effect3" then
      return 1
    end
  end,
  residue_func = function(self, player, skill, scope)
    if skill.trueName == "slash_skill" and scope == Player.HistoryPhase 
    and player:getMark("@[:]emo__yongyi-phase") == "emo__yongyi_effect2" then
      return 2
    end
  end,
}
emo__yongyi:addRelatedSkill(emo__yongyi_targetmod)

moe__bohe:addSkill(emo__yongyi)

local emo__yufu = fk.CreateTriggerSkill{
  name = "emo__yufu",
  anim_type = "drawcard",
  events = {fk.EventPhaseStart},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and target ~= player and target.phase == Player.Start then
      return table.every(player.room:getOtherPlayers(target), function (p) return p:getHandcardNum() < target:getHandcardNum() end)
    end
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(2, self.name)
  end,
}
moe__bohe:addSkill(emo__yufu)

local emo__guaai = fk.CreateTriggerSkill{
  name = "emo__guaai",
  anim_type = "negative",
  events = {fk.EventPhaseStart},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and target == player and target.phase == Player.Start then
      return player:isKongcheng()
    end
  end,
  on_use = function(self, event, target, player, data)
    player.room:loseHp(player, 1, self.name)
  end,
}
moe__bohe:addSkill(emo__guaai)


Fk:loadTranslationTable{
  ["moe__bohe"] = "薄荷",

  ["emo__yongyi"] = "雍仪",
  [":emo__yongyi"] = "出牌阶段限一次 ，你可以弃置任意张手牌并选择等量名角色，该角色的下一个出牌阶段获得一张【杀】和一个随机效果："..
  "<br>1.【杀】的伤害基数和抵消之需要的【闪】数+1；"..
  "<br>2.【杀】次数上限+2，被抵消时摸一张牌；"..
  "<br>3.【杀】无距离限制且目标上限+1；"..
  "<br>4.【杀】目标本回合非锁定技失效，普【杀】改为火【杀】；",

  ["@@emo__yongyi"] = "雍仪",
  ["#emo__yongyi_delay"] = "雍仪",
  ["@[:]emo__yongyi-phase"] = "雍仪",
  ["#emo__yongyi-prompt"] = "雍仪：弃置任意张手牌选择等量角色，其下个出牌阶段获得【杀】和增益",

  ["emo__yongyi_effect1"] = "无双",
  [":emo__yongyi_effect1"] = "【杀】的伤害基数和抵消之需要的【闪】数+1",
  ["emo__yongyi_effect2"] = "咆哮",
  [":emo__yongyi_effect2"] = "【杀】次数上限+2，被抵消时摸一张牌",
  ["emo__yongyi_effect3"] = "天义",
  [":emo__yongyi_effect3"] = "【杀】无距离限制且目标上限+1",
  ["emo__yongyi_effect4"] = "铁骑",
  [":emo__yongyi_effect4"] = "【杀】目标本回合非锁定技失效，普【杀】改为火【杀】",

  ["emo__yufu"] = "驭富",
  [":emo__yufu"] = "锁定技，其他角色的准备阶段，若其的手牌数为唯一最多，你摸两张牌。",

  ["emo__guaai"] = "寡爱",
  [":emo__guaai"] = "锁定技，准备阶段，若你没有手牌，你失去一点体力。",
}

local moe__junqingyao = General(extension, "moe__junqingyao", "moe", 3, 3, General.Female)

local emo__liushang = fk.CreateTriggerSkill{
  name = "emo__liushang",
  events = {fk.GameStart, fk.EventPhaseStart, fk.Damage, fk.Damaged},
  anim_type = "drawcard",
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) then return end
    if event == fk.GameStart then 
      return true
    elseif event == fk.Damage then
      return target == player
    elseif event == fk.Damaged then
      return target == player and #player:getPile("emo__cann") > 0
    else
      return (player.phase == Player.Start and #player:getPile("emo__cann") > 0) or (player.phase == Player.Finish)
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.GameStart  then
      local ids = {}
      for _, id in ipairs(room.draw_pile) do
        if table.every(ids, function(_id) return Fk:getCardById(_id).type ~= Fk:getCardById(id).type end) then
          table.insert(ids, id)
        end
        if #ids == 3 then break end
      end
      if #ids > 0 then
        player:addToPile("emo__cann", ids, true, self.name)
      end
    else
      if event == fk.Damage or (event == fk.EventPhaseStart and player.phase == Player.Finish) then
        player:addToPile("emo__cann", room:getNCards(1), true, self.name)
      else
        local cards = player:getPile("emo__cann")
        local cardId = #cards == 1 and cards[1]
        or room:askForCardChosen(player, player, { card_data = { { "emo__cann", cards } } }, self.name, "#emo__liushang-prey")
        room:moveCardTo(cardId, Card.PlayerHand, player, fk.ReasonPrey, self.name)
      end
    end
  end,
}
moe__junqingyao:addSkill(emo__liushang)

local emo__xianyou = fk.CreateTriggerSkill{
  name = "emo__xianyou",
  events = {fk.TargetSpecified, fk.AfterCardTargetDeclared},
  frequency = Skill.Compulsory,
  derived_piles = "emo__cann",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and #player:getPile("emo__cann") > 0 then
      if event == fk.TargetSpecified then
        return table.find(player:getPile("emo__cann"), function(id) return Fk:getCardById(id).type == Card.TypeEquip end)
        and data.card.is_damage_card and target.id ~= data.to and (target == player or player.id == data.to)
        and not player.room:getPlayerById(data.to).dead
      elseif table.find(player:getPile("emo__cann"), function(id) return Fk:getCardById(id).type == Card.TypeTrick end) and data.card:isCommonTrick() then
        local targets = U.getUseExtraTargets(player.room, data, true)
        if target ~= player then
          return table.contains(targets, player.id)
        else
          return #targets > 0
        end
      end
    end
  end,
  on_cost = function (self, event, target, player, data)
    if event == fk.TargetSpecified then return true end
    local room = player.room
    if target == player then
      local tos = player.room:askForChoosePlayers(player, U.getUseExtraTargets(room, data, true), 1, 1, "#emo__xianyou-choose:::"..data.card:toLogString(), self.name, true)
      if #tos > 0 then
        self.cost_data = tos
        return true
      end
    else
      return room:askForSkillInvoke(target, self.name, nil, "#emo__xianyou-invoke::"..player.id..":"..data.card:toLogString())
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.TargetSpecified  then
      room:getPlayerById(data.to):drawCards(1, self.name)
    else
      if target == player then
        table.insert(data.tos, self.cost_data)
      else
        room:doIndicate(target.id, {player.id})
        table.insert(data.tos, {player.id})
      end
    end
  end,
}
local emo__xianyou_targetmod = fk.CreateTargetModSkill{
  name = "#emo__xianyou_targetmod",
  bypass_times = function(self, from, skill, scope, card, to)
    return to and from ~= to and table.find({from, to}, function (p)
      return p:hasSkill(emo__xianyou) and table.find(p:getPile("emo__cann"), function(id) return Fk:getCardById(id).type == Card.TypeBasic end) ~= nil
    end)
  end,
  bypass_distances = function(self, from, skill, card, to)
    return to and table.find({from, to}, function (p)
      return p:hasSkill(emo__xianyou) and table.find(p:getPile("emo__cann"), function(id) return Fk:getCardById(id).type == Card.TypeBasic end) ~= nil
    end)
  end,
}
emo__xianyou:addRelatedSkill(emo__xianyou_targetmod)
moe__junqingyao:addSkill(emo__xianyou)


Fk:loadTranslationTable{
  ["moe__junqingyao"] = "君青瑶",

  ["emo__liushang"] = "流觞",
  [":emo__liushang"] = "锁定技，游戏开始时，你将牌堆中每种类型各一张牌置于你武将牌上称为“觞”。准备阶段或你受到伤害后，你获得一张“觞”；结束阶段或你造成伤害后，将牌堆顶一张牌置入“觞”中。",
  ["emo__cann"] = "觞",
  ["#emo__liushang-prey"] = "流觞：获得一张“觞”",

  ["emo__xianyou"] = "闲游",
  [":emo__xianyou"] = "锁定技，若你的“觞”中有：基本牌，你/其他角色对其他角色/你使用牌没有次数和距离限制；装备牌，你/其他角色使用伤害牌指定其他角色/你为目标后，后者摸一张牌；锦囊牌，你/其他角色使用普通锦囊牌可以额外指定一名其他角色/你为目标（无距离限制）。",
  ["#emo__xianyou-choose"] = "闲游：你可以为%arg额外指定一个目标",
  ["#emo__xianyou-invoke"] = "闲游：你可以指定 %dest 为%arg的额外目标",
}















--[[

Fk:loadTranslationTable{
  [""] = "",

  [""] = "",
  [""] = "",
  [""] = "",
  [""] = "",
  [""] = "",
  [""] = "",
  [""] = "",
  [""] = "",
  [""] = "",
  [""] = "",
  [""] = "",
}

--]]





return extension



